Posted 16 May 2012 - 11:26 PM
Spoiler
function setDoorColorGroup()
colors.combine(doors)
end
function SetTableUnlock()
t = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
end
function setTableLock()
t = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
end
function preparePrint()
term.clear()
term.setCursorPos(1,1)
print("L-tech Door Control System v2.0")
print("U = Unlocked, L = Locked")
print(" ")
print("# State")
end
function checkDoor1()
if t[1] == 1
then colors.combine(doors, colors.white)
print("1 U")
else colors.subtract(doors, colors.white)
print("1 L)")
end
end
function checkDoor2()
if t[2] == 1
then colors.combine(doors, colors.orange)
print("2 U")
else colors.subtract(doors, colors.orange)
print("2 L")
end
end
function checkDoor3()
if t[3] == 1
then colors.combine(doors, colors.magenta)
print("3 U")
else colors.subtract(doors, colors.magenta)
print("3 L")
end
end
function checkDoor4()
if t[4] == 1
then colors.combine(doors, colors.lightBlue)
print("4 U")
else colors.subtract(doors, colors.lightBlue)
print("4 L")
end
end
function checkDoor5()
if t[5] == 1
then colors.combine(doors, colors.yellow)
print("5 U")
else colors.subtract(doors, colors.yellow)
print("5 L")
end
end
function checkDoor6()
if t[6] == 1
then colors.combine(doors, colors.lime)
print("6 U")
else colors.subtract(doors, colors.lime)
print("6 L")
end
end
function checkDoor7()
if t[7] == 1
then colors.combine(doors, colors.pink)
print("7 U")
else colors.subtract(doors, colors.pink)
print("7 L")
end
end
function checkDoor8()
if t[8] == 1
then colors.combine(doors, colors.gray)
print("8 U")
else colors.subtract(doors, colors.gray)
print("8 L")
end
end
function checkDoor9()
if t[9] == 1
then colors.combine(doors, colors.lightGray)
print("9 U")
else colors.subtract(doors, colors.lightGray)
print("9 L")
end
end
function checkDoor10()
if t[10] == 1
then colors.combine(doors, colors.cyan)
print("10 U")
else colors.subtract(doors, colors.cyan)
print("10 L")
end
end
function checkDoor11()
if t[11] == 1
then colors.combine(doors, colors.purple)
print("11 U")
else colors.subtract(doors, colors.purple)
print("11 L")
end
end
function checkDoor12()
if t[12] == 1
then colors.combine(doors, colors.blue)
print("12 U")
else colors.subtract(doors, colors.blue)
print("12 L")
end
end
function checkDoor13()
if t[13] == 1
then colors.combine(doors, colors.brown)
print("13 U")
else colors.subtract(doors, colors.brown)
print("13 L")
end
end
function checkDoor14()
if t[14] == 1
then colors.combine(doors, colors.green)
print("14 U")
else colors.subtract(doors, colors.green)
print("14 L")
end
end
function checkDoor15()
if t[15] == 1
then colors.combine(doors, colors.red)
print("15 U")
else colors.subtract(doors, colors.red)
print("15 L")
end
end
function checkDoor16()
if t[16] == 1
then colors.combine(doors, colors.black)
print("16 U")
else colors.subtract(doors, colors.black)
print("16 L")
end
end
function runDoorCheck()
preparePrint()
checkDoor1()
checkDoor2()
checkDoor3()
checkDoor4()
checkDoor5()
checkDoor6()
checkDoor7()
checkDoor8()
checkDoor9()
checkDoor10()
checkDoor11()
checkDoor12()
checkDoor13()
checkDoor14()
checkDoor15()
checkDoor16()
changeDoor()
end
function changeDoor()
i = read
if i == lock then
c = t[i]+1
setTableLock()
changeDoor()
elseif input == unlock then
t = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
changeDoor()
elseif i == refresh then
runDoorCheck()
elseif i == 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or 10 or 11 or 12 or 13 or 14 or 15 or 16 then
table.insert(t,i,c)
if t[i] >= 2 then
table.insert(t,i,0)
runDoorCheck()
else
runDoorCheck()
end
else print("Command Not Recognized")
changeDoor()
end
end
function startup()
setDoorColorGroup()
SetTableUnlock()
runDoorCheck()
end
startup()
java.lang.ArrayIndexOutOfBoundsException: 256"
I would like help from people who have been working with this longer than I have to resolve it. I am running CC on minecraft 1.1 as of now since I have been running a Tekkit server since it's easier for my friends (Read: noobs) to join. Otherwise, I would not be using it, as I don't want or need a lot of what they threw in.
Anyways, the program is intended to use bundled cable on the back of the computer to control all 16 colors of insulated wire to some redpower AND gates which would open iron doors only if the computer is sending a signal and the button by the door is pressed. I would also probably switch to a password protected computer for the second signal at some point.
I've written a few other programs but this is the first time I've used tables to store variables, so if you could also help with the coding I would appreciate it.
I've been using Notepad++ to code it, its definitely much easier than the in game editor :P/>/>
Also, I have been looking into it with various searches and didn't come up with much, however I am fairly sure it is simply an error with how I coded something. Thanks, L5132