Advertisement
Guest User

ComputerCraft Passworded and Alarmed Door

a guest
Apr 27th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. password = "pass"
  2. debug = "debug"
  3.  
  4. doorSide = "right"
  5. doorTime = 4
  6.  
  7. alarmSide = "left"
  8. alarmTime = 10
  9.  
  10. -------------------------------------------------------------
  11.  
  12. term.clear()
  13. term.setCursorPos(1, 1)
  14.  
  15. write("Enter your password: ")
  16. input = read("*")
  17.  
  18. term.clear()
  19. term.setCursorPos(1, 1)
  20.  
  21. if input == password then
  22.     textutils.slowPrint("Password Correct!")
  23.     term.setCursorPos(1, 2)
  24.     print("The door will open now for " .. doorSide .. " seconds")
  25.     rs.setOutput(doorSide, true)
  26.     sleep(doorTime)
  27.     rs.setOutput(doorSide, false)
  28.     os.reboot()
  29. elseif input == debug then
  30.     exit()
  31.     term.clear()
  32. else
  33.     textutils.slowPrint("Password Incorrect!")
  34.     term.setCursorPos(1, 2)
  35.     textutils.slowPrint("Run Away!")
  36.     rs.setOutput(alarmSide, true)
  37.     sleep(alarmTime)
  38.     rs.setOutput(alarmSide, false)
  39.     os.reboot()
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement