Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modem = peripheral.find("modem") or error("No modem attached!")
- local monitor = peripheral.wrap("monitor_2") or print("Monitor unavailable.. Status wont be indicated.")
- modem.open(43)
- print("This is a secure environment! Please enter the password.")
- local input = read()
- if input == "verysecurepassword123" then
- print("What would you like to do? SHUTDOWN or OPERATE")
- local toDo = read()
- if toDo == "SHUTDOWN" then
- if monitor then
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write("SHUTDOWN SEQUENCE")
- end
- print("SHUTDOWN sequence initiated!")
- sleep(1)
- modem.transmit(43, 43, "SHUTDOWN")
- while true do
- local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- if channel == 45 then
- local identifier, action = message:match("^(%w+)%s+(%d+)$")
- if action == "SHUTDOWN" then
- if monitor then
- local cx, cy = monitor.getCursorPos()
- monitor.setCursorPos(cx + 1, cy + 1)
- monitor.write(identifier .. " HAS SHUT DOWN")
- end
- print(identifier .. " HAS SHUT DOWN")
- end
- end
- sleep(0.5)
- end
- elseif toDo == "OPERATE" then
- if monitor then
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write("OPERATE SEQUENCE")
- end
- print("OPERATE sequence initiated!")
- sleep(1)
- modem.transmit(43, 43, "OPERATE")
- while true do
- local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- if channel == 43 then
- local identifier, action = message:match("^(%w+)%s+(%d+)$")
- if action == "OPERATIVE" then
- if monitor then
- local cx, cy = monitor.getCursorPos()
- monitor.setCursorPos(cx + 1, cy + 1)
- monitor.write(identifier .. " IS OPERATIVE")
- end
- print(identifier .. " IS OPERATIVE")
- end
- end
- sleep(0.5)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement