Advertisement
Guest User

Untitled

a guest
Nov 4th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw -- Cancelles CTRL T
  2.  
  3. -- Variables
  4. username = "finnanut"
  5. sudoUser = "toor"
  6. password = "inmybutt"
  7. attemptsMade = 0
  8.  
  9. doorSide = "bottom"
  10.  
  11. local center = function(text)
  12. maxW, mxH = term.getSize()
  13. cursorX, cursorY = term.getCursorPos()
  14.  
  15. term.setCursorPos((maxW - #text) / 2, cursorY)
  16. write(text)
  17. term.setCursorPos(cursorX, cursorY + 1)
  18. end
  19.  
  20. function checkAttempts()
  21. if attemptsMade > 2 then
  22. term.clear()
  23. term.setCursorPos(1, 1)
  24. center("Too many attempts have been made.")
  25. center("Please try again in 2 minutes.")
  26. sleep(120)
  27. os.reboot()
  28. end
  29. end
  30.  
  31. function doLogin()
  32. checkAttempts()
  33.  
  34. term.clear()
  35.  
  36. if attemptsMade > 0 then
  37. center("Attempts made: " .. attemptsMade)
  38. end
  39.  
  40. write("Username: ")
  41. userInput = read()
  42.  
  43. if userInput == sudoUser then
  44. term.clear()
  45. term.setCursorPos(1, 1)
  46. center("Welcome into the computer.")
  47.  
  48. elseif userInput == username then
  49. write("Password: ")
  50. passwordInput = read("*")
  51.  
  52. if passwordInput == password then
  53. term.clear()
  54. term.setCursorPos(1, 1)
  55. center("Welcome back.")
  56.  
  57. sleep(1)
  58. rs.setOutput(doorSide, true)
  59. sleep(2)
  60. rs.setOutput(doorSide, false)
  61.  
  62. term.setCursorPos(1, 1)
  63. os.reboot()
  64.  
  65. else
  66. term.clear()
  67. center("Incorrect password.")
  68. attemptsMade = attemptsMade + 1
  69. sleep(1)
  70. term.clear()
  71. term.setCursorPos(1, 1)
  72. doLogin()
  73. end
  74. else
  75. term.clear()
  76. term.setCursorPos(1, 1)
  77. center("Incorrect username.")
  78. attemptsMade = attemptsMade + 1
  79. sleep(1)
  80. term.clear()
  81. term.setCursorPos(1, 1)
  82. doLogin()
  83. end
  84. end
  85.  
  86. doLogin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement