Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- password = "468"
- maxTries = 3
- numFails = 0
- os.pullEvent = os.pullEventRaw
- function checkPassword()
- term.clear()
- term.setCursorPos(1,1)
- print("Enter the password")
- input = read("*")
- if input == password then
- numFails = 0
- return true
- else
- numFails = numFails + 1
- return false
- end
- end
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print("What do you want to do?")
- print("1=Open Door")
- print("2=Close Door")
- print("3=Turn on Lights")
- print("4=Turn off Lights")
- input = io.read()
- if input == "1" then
- if checkPassword() == true then
- rs.setOutput("bottom",true)
- else
- term.clear()
- term.setCursorPos(1,1)
- print("Invalid Password")
- if numFails < maxTries then
- sleep(2)
- else
- print("Too many fails. Please wait")
- sleep(30)
- end
- end
- elseif input == "2" then
- rs.setOutput("bottom",false)
- elseif input == "3" then
- rs.setOutput("back",false)
- elseif input == "4" then
- rs.setOutput("back",true)
- elseif input == "bd" then
- break
- else
- print("Invalid")
- sleep(2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement