Posted 16 May 2015 - 03:34 AM
Sorry for the most basic of questions, but maybe one of you can give me a direction.
The code below is a basic password lock system. After receiving the correct password, the terminal gives the option of which door to open by input from the user. The problem is, the program accepts the first input in the function "input", but it doesn't accept the second or third input from the elseif statement. The code works perfectly otherwise. What am I missing?
Thank you!
The code below is a basic password lock system. After receiving the correct password, the terminal gives the option of which door to open by input from the user. The problem is, the program accepts the first input in the function "input", but it doesn't accept the second or third input from the elseif statement. The code works perfectly otherwise. What am I missing?
Thank you!
oldPull = os.pullEvent
os.pullEvent = os.pullEventRaw
function access()
term.clear()
term.setCursorPos(1,1)
print("Access Reactor or Security?")
write("Access: ")
input()
os.reboot()
end
function input()
if read() == "reactor" then
redstone.setOutput("right", true)
sleep(4)
redstone.setOutput("right", false)
sleep(1)
elseif read() == "security" then
redstone.setOutput("left", true)
sleep(4)
redstone.setOutput("left", false)
sleep(1)
else
print("Incorrect Input")
print("Try Again")
end
end
function open()
redstone.setOutput("left", true)
sleep(3)
redstone.setOutput("left", false)
end
while true do
term.clear()
term.setCursorPos(1,1)
print("RESTRICTED ACCESS")
write("Password: ")
if read("*") == "lemon" then
print("Access Granted.")
-- open()
access()
os.reboot()
else
print("Access Denied")
sleep(2)
os.reboot()
end
end