grubert89

Login

Jan 4th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. local w, h = term.getSize()
  3. --Variables
  4. local user = "Human"
  5. local pass = "password"
  6. local uAllow = false
  7. local pAllow = false
  8. version = "1.0.0"
  9. --Functions
  10. function clear()
  11. term.clear()
  12. term.setCursorPos(1,1)
  13. end
  14. function printCentered(msg, h)
  15. term.setCursorPos(w/2 - #msg/2, h)
  16. write(msg)
  17. end
  18. local function printHeader()
  19. printCentered("Login System V"..version, 1)
  20. printCentered("Coded by: Human", 2)
  21. end
  22. local function uCheck()
  23. write("Username: ")
  24. uInput = read()
  25. if uInput == user then
  26. uAllow = true
  27. else
  28. print("Incorrect Username!")
  29. sleep(2)
  30. os.reboot()
  31. end
  32. end
  33. local function pCheck()
  34. write("Password: ")
  35. pInput = read("*")
  36. if pInput == pass then
  37. pAllow = true
  38. else
  39. print("Incorrect Password!")
  40. sleep(2)
  41. os.reboot()
  42. end
  43. end
  44. --Main Program
  45. clear()
  46. printHeader()
  47. term.setCursorPos(1,4)
  48. uCheck()
  49. if uAllow == true then
  50. term.setCursorPos(1,5)
  51. pCheck()
  52. end
  53. if uAllow == true and pAllow == true then
  54. textutils.slowPrint("Loging in...")
  55. sleep(2)
  56. clear()
  57. print("Logged in")
  58. end
Add Comment
Please, Sign In to add comment