Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- password = "space"
- maxTries = 5
- numFails = 0
- local oldPullEvent = os.pullEvent
- os.pullEvent = os.pullEventRaw
- function checkPassword()
- term.clear()
- term.setCursorPos(1,1)
- print("Password?")
- answer = read("*")
- if answer == password then
- numfails = 0
- return true
- else
- numfails = numfails + 1
- return false
- end
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print("Yes?")
- print("Open")
- print("Close")
- input = io.read()
- if input == "Open" then
- if checkPassword() == true then
- rs.setOutput("left",true)
- else
- term.clear()
- term.setCursorPos(1,1)
- print("Incorrect")
- if numFails < maxTries then
- sleep(2)
- else
- print("Try again later")
- sleep(30)
- end
- end
- elseif input == "Close" then
- rs.setOutput("left",false)
- elseif input == "out" then
- break
- else
- print("Invalid Entry")
- end
- end
Add Comment
Please, Sign In to add comment