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()
doorControlLoop()
end
function changeDoor()
i = read
if i == lock then
c = t[i]+1
t = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
elseif i == unlock then
t = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
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")
end
end
function doorControlLoop()
while true do
changeDoor()
end
end
function startup()
setDoorColorGroup()
SetTableUnlock()
doorControlLoop()
end
startup()