Guest User

Untitled

a guest
Feb 12th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. function again()
  2. term.clear()
  3. term.setCursorPos(1,1)
  4. term.setCursorPos(14,7)
  5. print" Log in/create new user"
  6. term.setTextColor(colors.red)
  7. term.setBackgroundColor(colors.black)
  8. term.setCursorPos(12,9)
  9. print"|New |"
  10. term.setCursorPos(12,10)
  11. print"|User|"
  12. term.setCursorPos(33,9)
  13. print"|Log |"
  14. term.setCursorPos(33,10)
  15. print"| In |"
  16. term.setBackgroundColor(colors.white)
  17. local running=true
  18. while running==true do
  19.   event,button,x,y = os.pullEvent("mouse_click")
  20.   if (x>=33) and (x<=42) and (y>=9) and (y<=10) then
  21.     shell.run"login"
  22.     running=false
  23.   elseif (x>=12) and (x<=18) and (y>=9) and (y<=10) then
  24.       shell.run"NewUser"
  25.   end
  26. end
  27. end
  28.  
  29. term.setBackgroundColor(colors.white)
  30. term.clear()
  31. term.setCursorPos(17,10)
  32. term.setTextColor(colors.red)
  33. print"Username:"
  34. term.setCursorPos(17,11)
  35. print"Password:"
  36. term.setCursorPos(26,10)
  37. term.setTextColor(colors.black)
  38. username=read()
  39. term.setCursorPos(26,11)
  40. password=read("*")
  41. if fs.exists("users/"..username) then
  42.   file=fs.open("users/"..username,"r")
  43.   local pass=file.readLine()
  44.   if password==pass then
  45.     print("                Loged in as " ..username)
  46.     file.close()
  47.     sleep(3)
  48.     term.setBackgroundColor(colors.black)
  49.     term.clear()
  50.     term.setCursorPos(1,1)
  51.   else
  52.     print"                Incorrect password"
  53.     sleep(3)
  54.     again()
  55.   end
  56. else
  57.   print"                Unknown username"
  58.   sleep(3)
  59.   again()
  60. end
Add Comment
Please, Sign In to add comment