Advertisement
Guest User

passwordlock

a guest
Oct 12th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. -- Neat version
  2.  
  3. os.pullEvent = os.pullEventRaw
  4.  
  5. local accounts = {
  6.   {
  7.     username = "Sasha_King",
  8.     password = "CC54"
  9.   },
  10. }
  11.  
  12. term.clear()
  13. term.setCursorPos(1,1)
  14.  
  15. print([[
  16.  
  17.  .__________________________.
  18.  |                          |
  19.  | Login:                   |
  20.  | Password:                |
  21.  |                          |
  22.  |                          |
  23.  |__________________________|
  24. ]])
  25.  
  26. term.setCursorPos(11, 4)
  27. local username = read()
  28. term.setCursorPos(14, 5)
  29. local password = read("*")
  30.  
  31. local exists = false
  32. for i=1,#accounts,1 do
  33.   if username == accounts[i].username and password == accounts[i].password then
  34.     exists = true
  35.     break
  36.   end
  37. end
  38.  
  39. term.setCursorPos(4, 7)
  40. if exists then
  41.   term.write("Access Granted!")
  42.   term.setCursorPos(1, 10)
  43. else
  44.   term.write("Access Denied!")
  45.   sleep(1)
  46.   os.shutdown()
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement