Guest User

CC Password Door Attempt

a guest
Nov 25th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. password = "space"
  2. maxTries = 5
  3. numFails = 0
  4. local oldPullEvent = os.pullEvent
  5. os.pullEvent = os.pullEventRaw
  6. function checkPassword()
  7.     term.clear()
  8.     term.setCursorPos(1,1)
  9.     print("Password?")
  10.     answer = read("*")
  11.     if answer == password then
  12.         numfails = 0
  13.         return true
  14.     else
  15.         numfails = numfails + 1
  16.         return false
  17. end
  18. while true do
  19.     term.clear()
  20.     term.setCursorPos(1,1)
  21.     print("Yes?")
  22.     print("Open")
  23.     print("Close")
  24.     input = io.read()
  25.     if input == "Open" then
  26.         if checkPassword() == true then
  27.             rs.setOutput("left",true)
  28.         else
  29.             term.clear()
  30.             term.setCursorPos(1,1)
  31.             print("Incorrect")
  32.             if numFails < maxTries then
  33.                 sleep(2)
  34.             else
  35.                 print("Try again later")
  36.                 sleep(30)
  37.             end
  38.         end
  39.     elseif input == "Close" then
  40.         rs.setOutput("left",false)
  41.     elseif input == "out" then
  42.         break
  43.     else
  44.         print("Invalid Entry")
  45.     end
  46. end
Add Comment
Please, Sign In to add comment