Posted 24 January 2013 - 02:34 PM
Well, this is a security/door program. When the user presses space it is meant to toggle the state from open to closed, or vice-versa. Anyone know why this isn't doing as intended?
function updateText()
os.sleep(1)
term.clear()
door1()
door1scan()
updateText()
end
function door1()
if doorStat1 == true then
term.setCursorPos(1,2)
term.clearLine()
term.setTextColor(colors.green)
term.write"Door 1 is OPEN."
else
term.setCursorPos(1,2)
term.clearLine()
term.setTextColor(colors.red)
term.write"Door 1 is CLOSED"
end
end
function door1scan()
local event, scancode = os.pullEvent("key")
if scancode == 57 and doorStat1 == false then
doorStat1 = true
end
if scancode == 57 and doorStat1 == true then
doorStat1 = not doorStat1
end
end
updateText()