Advertisement
PrinceOfCookies

Untitled

Jan 25th, 2023
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. term.clear()
  2.  
  3. -- CID: 2.2
  4. term.setCursorPos(1,1)
  5. print("Password:")
  6. os.pullEvent = os.pullEventRaw
  7. local input = read("*")
  8.  
  9. local function openDoor()
  10. sleep(0.2)
  11. rs.setOutput("back", true)
  12. sleep(3)
  13. os.reboot()
  14. end
  15.  
  16. local options = {{
  17. name = "Open Door",
  18. func = openDoor
  19. }, {
  20. name = "Reboot",
  21. func = os.reboot
  22. }}
  23.  
  24. local w, h = term.getSize()
  25. local red = colors.red
  26. local green = colors.green
  27. local white = colors.white
  28.  
  29. local function displayAccessGranted()
  30. term.clear()
  31. local message = "Access Granted"
  32. local x, y = math.floor(w / 2) - math.floor(string.len(message) / 2), math.floor(h / 2)
  33. term.setCursorPos(x, y)
  34. term.setTextColor(green)
  35. print(message)
  36. sleep(1)
  37. end
  38.  
  39. local function displayAccessDenied()
  40. sleep(0.2)
  41. term.clear()
  42. local message = "Access Denied"
  43. local x, y = math.floor(w / 2) - math.floor(string.len(message) / 2), math.floor(h / 2)
  44. term.setCursorPos(x, y)
  45. term.setTextColor(red)
  46. print(message)
  47. sleep(1)
  48. os.reboot()
  49. end
  50.  
  51. local function displayInvalidOption()
  52. sleep(0.2)
  53. term.clear()
  54. local message = "That's not a valid option."
  55. local x, y = math.floor(w / 2) - math.floor(string.len(message) / 2), math.floor(h / 2)
  56. term.setCursorPos(x, y)
  57. term.setTextColor(red)
  58. print(message)
  59. sleep(1)
  60. os.reboot()
  61. end
  62.  
  63. local function displayMenu()
  64. sleep(0.2)
  65. term.clear()
  66. term.setTextColor(white)
  67. term.setCursorPos(1, 1)
  68. print("What would you like to do now?")
  69. for i = 1, #options do
  70. print(string.format("[%d] %s", i, options[i].name))
  71. end
  72. end
  73.  
  74. if input == "124" then
  75. sleep(0.2)
  76. displayAccessGranted()
  77. sleep(0.2)
  78. displayMenu()
  79. local input2 = read()
  80. local option = tonumber(input2)
  81. if option and options[option] then
  82. options[option].func()
  83. else
  84. displayInvalidOption()
  85. end
  86. else
  87. displayAccessDenied()
  88. end
  89.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement