Advertisement
Guest User

startup

a guest
Mar 31st, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. local side = "back"
  2. local password = "ilaria"
  3. local quit = "ilva"
  4. local openTime = 2
  5. local c = true
  6.  
  7. local pullEvent = os.pullEvent
  8. os.pullEvent = os.pullEventRaw
  9.  
  10. function resetTerm()
  11.   term.clear()
  12.   term.setCursorPos(1, 1)
  13. end
  14.  
  15. while c do
  16.   resetTerm()
  17.  
  18.   write("Password: ")
  19.   local input = read("*")
  20.  
  21.   if input == password then
  22.     rs.setOutput(side, true)
  23.    
  24.     local i = openTime
  25.     while i >= 1 do
  26.       resetTerm()
  27.       print("Password corretta\nChiusura tra "..i.." secondi")
  28.      
  29.       i = i - 1
  30.      
  31.       sleep(1)
  32.     end
  33.    
  34.     rs.setOutput(side, false)
  35.     resetTerm()
  36.   elseif input == quit then
  37.     print ("Uscita richiesta da utente")
  38.     c = false
  39.     os.pullEvent = pullEvent
  40.   else
  41.     resetTerm()
  42.    
  43.     print("Password non riconosciuta")
  44.     sleep(2)
  45.   end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement