Advertisement
tobast

Untitled

Apr 19th, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. -- By Tobast
  2.  
  3. os.pullEvent = os.pullEventRaw
  4.  
  5. -- SETTINGS
  6. PASSWORD = "CHANGE ME"
  7. MAINTENANCE_PASS = "MAINTENANCE"
  8. SIDE = "bottom"
  9. DELAY = 5
  10. -- END SETTINGS
  11.  
  12. function clear()
  13.     term.clear()
  14.     term.setCursorPos(1,1)
  15. end
  16. function newline()
  17.     x,y = term.getCursorPos()
  18.     term.setCursorPos(1,y+1)
  19. end
  20.  
  21. badPasswdCount = 0
  22.  
  23. while true do
  24.     clear()
  25.     write("Please type in the access code.")
  26.     newline()
  27.     passwd = read("*")
  28.    
  29.     if passwd == PASSWORD then
  30.         clear()
  31.         if badPasswdCount > 0 then
  32.             write(tostring(badPasswdCount).." wrong tries!")
  33.             badPasswdCount=0
  34.             newline()
  35.             newline()
  36.         end
  37.         write("Access granted!")
  38.         redstone.setOutput(SIDE, true)
  39.         sleep(DELAY)
  40.         redstone.setOutput(SIDE, false)
  41.    
  42.     elseif passwd == MAINTENANCE_PASS then
  43.         clear()
  44.         write("Don't forget to reboot when you're done!")
  45.         newline()
  46.         break
  47.     else
  48.         clear()
  49.         write("Access denied.")
  50.         badPasswdCount = badPasswdCount + 1
  51.         sleep(1)
  52.     end
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement