Advertisement
jille_Jr

CC: Security #1 password

Oct 9th, 2012
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Security #1
  2. -- Password lock
  3. -- Code written by jag_e_nummer_ett
  4.  
  5. local oldPull = os.pullEvent;
  6. os.pullEvent = os.pullEventRaw;
  7.  
  8. function login()
  9.   local password = "password"
  10.   local inputPass = ""
  11.   local tries = 5
  12.   while inputPass ~= password do
  13.     term.clear()
  14.     if tries < 5 then
  15.       term.setCursorPos(3,5)
  16.       print("Incorrect password!")
  17.     end
  18.     term.setCursorPos(3,2)
  19.     print("Please enter password")
  20.     term.setCursorPos(3,4)
  21.     print("Tries left: "..tries)
  22.     term.setCursorPos(3,3)
  23.     write("Password: ")
  24.     inputPass = read("*")
  25.     tries = tries - 1
  26.     if tries == 0 then
  27.       return false
  28.     end
  29.   end
  30.   return true
  31. end
  32.  
  33. if login() then
  34.   term.clear()
  35.   term.setCursorPos(3,2)
  36.   print("Login successful!")
  37.   sleep(1.5)
  38. else
  39.   term.clear()
  40.   term.setCursorPos(3,2)
  41.   print("Login failed!")
  42.   sleep(1.5)
  43.   os.shutdown()
  44. end
  45.  
  46. os.pullEvent = oldPull;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement