Advertisement
PrinceOfCookies

sec d

Jan 25th, 2023
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. local tscp = term.setCursorPos -- set cursor pos
  2. local tcl = term.clearLine -- clear line
  3. local tw = term.write -- write
  4. local tc = term.clear -- clear
  5. local tgs = term.getSize -- get size
  6. local tstc = term.setTextColor
  7. local tsbc = term.setBackgroundColor
  8.  
  9. term.clear()
  10.  
  11. -- CID: 2.2
  12. term.setCursorPos(1,1)
  13. print("Password:")
  14. os.pullEvent = os.pullEventRaw
  15. local input = read("*")
  16.  
  17. local function openDoor()
  18. sleep(0.2)
  19. rs.setOutput("left", true)
  20. sleep(3)
  21. os.reboot()
  22. end
  23.  
  24. local options = {{
  25. name = "Open Door",
  26. func = openDoor
  27. }, {
  28. name = "Reboot",
  29. func = os.reboot
  30. }}
  31.  
  32. local w, h = term.getSize()
  33. local red = colors.red
  34. local green = colors.green
  35. local white = colors.white
  36.  
  37. local function displayAccessGranted()
  38. tc()
  39. local message = "Access Granted"
  40. local x, y = math.floor(w / 2) - math.floor(string.len(message) / 2), math.floor(h / 2)
  41. tsbc(green)
  42. for i = 1, h do
  43. tscp(1, i)
  44. tw(" ")
  45. end
  46. tscp(x, y)
  47. tstc(black)
  48. print(message)
  49. sleep(1)
  50. tsbc(black)
  51. tstc(white)
  52. sleep(1)
  53. end
  54.  
  55. local function displayAccessDenied()
  56. sleep(0.2)
  57. term.clear()
  58. local message = "Access Denied"
  59. local x, y = math.floor(w / 2) - math.floor(string.len(message) / 2), math.floor(h / 2)
  60. tsbc(red)
  61. for i = 1, h do
  62. tscp(1, i)
  63. tw(" ")
  64. end
  65. tscp(x, y)
  66. tstc(black)
  67. print(message)
  68. sleep(1)
  69. tsbc(black)
  70. tstc(white)
  71. os.reboot()
  72. end
  73.  
  74.  
  75.  
  76. local function displayInvalidOption()
  77. sleep(0.2)
  78. term.clear()
  79. local message = "That's not a valid option."
  80. local x, y = math.floor(w / 2) - math.floor(string.len(message) / 2), math.floor(h / 2)
  81. term.setCursorPos(x, y)
  82. term.setTextColor(red)
  83. print(message)
  84. sleep(1)
  85. os.reboot()
  86. end
  87.  
  88. local function displayMenu()
  89. sleep(0.2)
  90. term.clear()
  91. term.setTextColor(white)
  92. term.setCursorPos(1, 1)
  93. print("What would you like to do now?")
  94. for i = 1, #options do
  95. print(string.format("[%d] %s", i, options[i].name))
  96. end
  97. end
  98.  
  99. if input == "5152" then
  100. sleep(0.2)
  101. displayAccessGranted()
  102. sleep(0.2)
  103. displayMenu()
  104. local input2 = read()
  105. local option = tonumber(input2)
  106. if option and options[option] then
  107. options[option].func()
  108. else
  109. displayInvalidOption()
  110. end
  111. elseif input = "12555" then
  112. sleep(0.2)
  113. displayAccessGranted()
  114. term.clear()
  115. else
  116. displayAccessDenied()
  117. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement