Advertisement
sasaa86

Computer craft password door

Aug 22nd, 2017
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. password = "1234"
  2. side = "left"
  3. opentime = 5
  4. invertedSignal = false
  5. local fail = 0
  6.  
  7. while true do
  8.     term.clear()
  9.     term.setCursorPos(1,1)
  10.     print() -- empty line
  11.     write("  Password: ")
  12.     input = read("*")
  13.     if input == password then
  14.         print("Access granted!")
  15.         if invertedSignal then
  16.             rs.setOutput(side, false)
  17.             sleep(opentime)
  18.             rs.setOutput(side, true)
  19.         else
  20.             rs.setOutput(side, true)
  21.             sleep(opentime)
  22.             rs.setOutput(side, false)
  23.         end
  24.     else
  25.         fail = fail+1
  26.         print("Access denied!")
  27.         if fail == 3 then
  28.             print("  Failed 3 times")
  29.             print("  Rebooting...")
  30.             sleep(2)
  31.             os.shutdown()
  32.         end
  33.     end
  34.     sleep(0.2)
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement