Advertisement
DOGGYWOOF

TEST"

Apr 5th, 2024
4
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. local MAX_ATTEMPTS = 3 -- Maximum number of incorrect password attempts allowed
  2. local LOCKOUT_TIME = 30 -- Lockout time in seconds after reaching maximum attempts
  3.  
  4. local USERS_FOLDER = "/disk/users/"
  5. local ERROR_FOLDER = "/disk/error/"
  6. local BSOD_PROGRAM = "BSOD.lua"
  7. local RECOVERY_PROGRAM = "/disk/boot/Recovery.lua"
  8.  
  9. local function getUserCredentials(username)
  10. local passwordFile = fs.combine(USERS_FOLDER .. username, "password.txt")
  11.  
  12. if fs.exists(passwordFile) then
  13. local file = fs.open(passwordFile, "r")
  14. local storedPassword = file.readLine()
  15. file.close()
  16. return storedPassword
  17. else
  18. return nil -- User does not exist
  19. end
  20. end
  21.  
  22. -- Define functions for drawing GUI elements
  23. local function drawGUI()
  24. term.setBackgroundColor(colors.red)
  25. term.clear()
  26. term.setCursorPos(1, 1)
  27. term.setTextColor(colors.white)
  28. term.write("Reboot")
  29. term.setCursorPos(1, 3)
  30. term.write("Shutdown")
  31. term.setCursorPos(1, 5)
  32. term.write("Reboot to Recovery")
  33. end
  34.  
  35. local function handleGUI()
  36. local selectedOption = 1
  37.  
  38. while true do
  39. drawGUI()
  40.  
  41. term.setCursorPos(1, selectedOption * 2 - 1)
  42. term.setTextColor(colors.red)
  43. term.write(">")
  44.  
  45. local _, key = os.pullEvent("key")
  46. if key == keys.up and selectedOption > 1 then
  47. selectedOption = selectedOption - 1
  48. elseif key == keys.down and selectedOption < 3 then
  49. selectedOption = selectedOption + 1
  50. elseif key == keys.enter then
  51. if selectedOption == 1 then
  52. -- Reboot
  53. term.clear()
  54. term.setCursorPos(1, 1)
  55. print("Rebooting...")
  56. os.sleep(2)
  57. os.reboot()
  58. elseif selectedOption == 2 then
  59. -- Shutdown
  60. term.clear()
  61. term.setCursorPos(1, 1)
  62. print("Shutting down...")
  63. os.sleep(2)
  64. os.shutdown()
  65. elseif selectedOption == 3 then
  66. -- Reboot to Recovery
  67. term.clear()
  68. term.setCursorPos(1, 1)
  69. print("Rebooting to Recovery...")
  70. os.sleep(3)
  71. shell.run(RECOVERY_PROGRAM)
  72. end
  73. end
  74. end
  75. end
  76.  
  77. -- Rest of your code...
  78.  
  79. local function main()
  80. -- Your existing code here...
  81. end
  82.  
  83. -- Intercept the terminate event
  84. local oldTerm = os.pullEvent
  85. os.pullEvent = function(event, ...)
  86. if event == "terminate" then
  87. print("Termination is not allowed.")
  88. return
  89. end
  90. return oldTerm(event, ...)
  91. end
  92.  
  93. main()
  94.  
  95. -- After main function call, start handling GUI
  96. handleGUI()
  97.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement