Guest User

startup

a guest
Feb 19th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. local oldPull = os.pullEvent
  2. os.pullEvent = os.pullEventRaw
  3.  
  4. local file = fs.open("/attempts","r")
  5. local attempts = file:readAll()
  6. file:close()
  7.  
  8. local password = "opensaysme"
  9. local devPassword = "opensaysmedev"
  10. local sleepTime = 2
  11. local programToOpenDoor = "/opendoor"
  12. local programToCloseDoor = "/closedoor"
  13.  
  14. while true do
  15.   term.clear()
  16.   term.setCursorPos(1,1)
  17.   if(attempts == maxAttempts) then
  18.     print("You have entered the incorrect password too many times!")
  19.     print("Computer has entered lockup mode. Please contact the administrator to unlock it.")
  20.     sleep(9999)    
  21.   end
  22.   print("Please enter the password!")
  23.   write("Password: ")
  24.  
  25.   input = read("*")
  26.   if(input == password) then
  27.     print("Password Correct!")
  28.     print("Door(s) opened for " .. sleepTime .. " seconds!")
  29.     shell.run(programToOpenDoor)
  30.     sleep(sleepTime)
  31.     shell.run(programToCloseDoor)
  32.     attempts = "0"
  33.     file:write(attempts)
  34.   elseif(input == devPassword) then
  35.     print("Developer password entered!")
  36.     print("Developer mode enabled...")
  37.     sleep(sleepTime)
  38.     term.clear()
  39.     term.setCursorPos(1,1)
  40.     os.pullEvent = oldPull
  41.     print(os.version() .. " [Developer Mode]")
  42.     break      
  43.   else
  44.     local file = fs.open("/attempts","w")
  45.     print("Incorrect password!")
  46.     print("Please try again...")
  47.     attempts = attempts +  1
  48.     file:write(attempts)
  49.     file:close()
  50.     sleep(sleepTime)
  51.   end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment