Advertisement
Guest User

Untitled

a guest
Nov 4th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 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 > 3 then
  22. term.clear()
  23. term.setCursorPos(1, 1)
  24. center("Too many attempts have been made, Please try again in 2 minutes.")
  25. sleep(120)
  26. os.reboot()
  27. end
  28. end
  29.  
  30. function doLogin()
  31. checkAttempts()
  32.  
  33. term.clear()
  34.  
  35. if attemptsMade > 0 then
  36. center("Attempts made: " .. attemptsMade)
  37. end
  38.  
  39. write("Username: ")
  40. userInput = read()
  41.  
  42. if userInput == sudoUser then
  43. term.clear()
  44. term.setCursorPos(1, 1)
  45. center("Welcome into the computer.")
  46.  
  47. elseif userInput == username then
  48. write("Password: ")
  49. passwordInput = read("*")
  50.  
  51. if passwordInput == password then
  52. term.clear()
  53. term.setCursorPos(1, 1)
  54. center("Welcome back.")
  55.  
  56. sleep(1)
  57. rs.setOutput(doorSide, true)
  58. sleep(2)
  59. rs.setOutput(doorSide, false)
  60.  
  61. term.setCursorPos(1, 1)
  62. os.reboot()
  63.  
  64. else
  65. term.clear()
  66. center("Incorrect password.")
  67. attemptsMade = attemptsMade + 1
  68. sleep(1)
  69. term.clear()
  70. term.setCursorPos(1, 1)
  71. doLogin()
  72. end
  73. else
  74. term.clear()
  75. term.setCursorPos(1, 1)
  76. center("Incorrect username.")
  77. attemptsMade = attemptsMade + 1
  78. sleep(1)
  79. term.clear()
  80. term.setCursorPos(1, 1)
  81. doLogin()
  82. end
  83. end
  84.  
  85. doLogin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement