Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tscp = term.setCursorPos -- set cursor pos
- local tcl = term.clearLine -- clear line
- local tw = term.write -- write
- local tc = term.clear -- clear
- local tgs = term.getSize -- get size
- local tstc = term.setTextColor
- local tsbc = term.setBackgroundColor
- term.clear()
- -- CID: 2.2
- term.setCursorPos(1,1)
- print("Password:")
- os.pullEvent = os.pullEventRaw
- local input = read("*")
- local function openDoor()
- sleep(0.2)
- rs.setOutput("left", true)
- sleep(3)
- os.reboot()
- end
- local options = {{
- name = "Open Door",
- func = openDoor
- }, {
- name = "Reboot",
- func = os.reboot
- }}
- local w, h = term.getSize()
- local red = colors.red
- local green = colors.green
- local white = colors.white
- local function displayAccessGranted()
- tc()
- local message = "Access Granted"
- local x, y = math.floor(w / 2) - math.floor(string.len(message) / 2), math.floor(h / 2)
- tsbc(green)
- for i = 1, h do
- tscp(1, i)
- tw(" ")
- end
- tscp(x, y)
- tstc(black)
- print(message)
- sleep(1)
- tsbc(black)
- tstc(white)
- sleep(1)
- end
- local function displayAccessDenied()
- sleep(0.2)
- term.clear()
- local message = "Access Denied"
- local x, y = math.floor(w / 2) - math.floor(string.len(message) / 2), math.floor(h / 2)
- tsbc(red)
- for i = 1, h do
- tscp(1, i)
- tw(" ")
- end
- tscp(x, y)
- tstc(black)
- print(message)
- sleep(1)
- tsbc(black)
- tstc(white)
- os.reboot()
- end
- local function displayInvalidOption()
- sleep(0.2)
- term.clear()
- local message = "That's not a valid option."
- local x, y = math.floor(w / 2) - math.floor(string.len(message) / 2), math.floor(h / 2)
- term.setCursorPos(x, y)
- term.setTextColor(red)
- print(message)
- sleep(1)
- os.reboot()
- end
- local function displayMenu()
- sleep(0.2)
- term.clear()
- term.setTextColor(white)
- term.setCursorPos(1, 1)
- print("What would you like to do now?")
- for i = 1, #options do
- print(string.format("[%d] %s", i, options[i].name))
- end
- end
- if input == "5152" then
- sleep(0.2)
- displayAccessGranted()
- sleep(0.2)
- displayMenu()
- local input2 = read()
- local option = tonumber(input2)
- if option and options[option] then
- options[option].func()
- else
- displayInvalidOption()
- end
- elseif input = "12555" then
- sleep(0.2)
- displayAccessGranted()
- term.clear()
- else
- displayAccessDenied()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement