Advertisement
Guest User

Password

a guest
Sep 25th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. local tUsers={
  2. --usernames,passwords                   --list of usernames and password
  3. {"abc","123"},
  4. {"abba","abc"},
  5. {"cba","dde"},
  6. }
  7.  
  8. function clear()                        -- clears the screen
  9. term.setCursorPos(1,1)
  10. term.clear()
  11. end
  12.  
  13.  
  14. clear()                                 -- clears the screen
  15. print("Username: ")
  16. print("Password: ")
  17. term.setCursorPos(10,1)
  18. local oldUse = read()                   --input username
  19. term.setCursorPos(10,2)
  20. local oldPas = read("*")                -- input old password
  21.  
  22. for i = 1,#tUsers do
  23.     if oldUse == tUsers[i][1] and oldPas == tUsers[i][2] then  -- compare username and password
  24.         clear()                         -- clears the screen
  25.         print("New password: ")
  26.         term.setCursorPos(14,1)
  27.         local newPass1 = read("*")      --input new password #1
  28.         clear()                         -- clears the screen
  29.         print("New Password: ")
  30.         print("Type your new password again")
  31.         sleep(.2)
  32.         term.setCursorPos(14,1)
  33.         local newPass2 = read("*")      -- input new password #2
  34.             if newPass1 == newPass2 then--compares your new passwords
  35.                 tUsers[i][2] = newPass1 -- if true change your old password
  36.             else
  37.                 clear()                 -- clears the screen
  38.                 print("Did you misspell your new password?")
  39.                 print("Pleas try again :)")
  40.                 sleep(1.5)
  41.             end
  42.         clear()                         -- clears the screen
  43.         print("Username:",tUsers[i][1])
  44.         print("New Pass:",tUsers[i][2])
  45.     end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement