Advertisement
Guest User

Untitled

a guest
Mar 4th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 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.     if fs.exists"loged-user" then
  48.       fs.delete"loged-user"
  49.     end
  50.     local file=fs.open("loged-user","a")
  51.     file.writeLine(username)
  52.     file.close()
  53.     sleep(3)
  54.     term.setBackgroundColor(colors.black)
  55.     term.clear()
  56.     term.setCursorPos(1,1)
  57.   else
  58.     print"                Incorrect password"
  59.     sleep(3)
  60.     again()
  61.   end
  62. else
  63.   print"                Unknown username"
  64.   sleep(3)
  65.   again()
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement