Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script for Bunker Control
- local component = require("component")
- local thread = require("thread")
- local event = require("event")
- local term = require("term")
- local serialization = require("serialization")
- local reds = component.redstone
- local sides = require("sides")
- local colors = require("colors")
- local modem = component.modem
- local gpu = component.gpu
- local debug_card = component.debug
- local lastMessageId = nil
- relay_address = "c4c7c470-2df1-49a0-9199-af7af3cdc989"
- user = ""
- Local_Name = "Epsilon Site"
- Short_Name = "[Epsilon] "
- running = true
- decon = false
- -- Configuration
- beacon = true
- modem.open(123)
- -- UI Drawing Function
- local function draw_ui()
- term.clear()
- print("Bunker Control")
- print("[SPACE] Toggle Emergency Beacon [" .. (beacon and "ON" or "OFF") .. "]")
- print("[D] " .. (decon and "Run Decontamination Procedure [RUNNING]" or "Run Decontamination Procedure"))
- print("[U] Update orders from high command")
- print("[M] Messages")
- print("[Q] Dial Omega Site")
- end
- -- UI Drawing Function messages
- local function draw_ui_messages()
- term.clear()
- print("Messages")
- print("[R] Read messages")
- print("[S] Send message")
- print("[E] Exit")
- end
- -- Function to send commands
- local function send_command(address, value, header)
- local data = {
- from = Local_Name,
- shrt = Short_Name,
- user = user,
- to = address,
- header = header,
- message = value,
- timestamp = os.time()
- }
- local serialized_data = serialization.serialize(data)
- modem.send(relay_address, 123, serialized_data)
- end
- -- Function to read messages
- local function read_message()
- ::continue1::
- term.clear()
- print("Inbox")
- print("Pick a message to read")
- print("︱NEWEST︱")
- print("[1] ︱ [Omega] ComE ︱")
- print("[2] ︱ [ALERT] LOCKDOWN INITIATED ︱")
- print("[3] ︱ [Lab 1] Missing Shipment ︱")
- print("[4] ︱ [Lab 2] Lab results ︱")
- print("[5] ︱ [Omega] Iris installed ︱")
- print("[6] ︱ [High cmd] Increased activity READ ME︱")
- print("[7] ︱ [Lab 2] Eggsacks ︱")
- print("︱OLDEST︱")
- print("")
- print("")
- print("[E] Exit")
- local answer = io.read()
- if answer == "1" then
- term.clear()
- print("︱ [Omega] ComE ︱")
- print("")
- print("Join us, we lvie in hramony, the msnoetrs are gone, we cannot aecscc your wold,")
- print("you will cmoe to ouesr, cmoe cmoe, Alvin missse you all")
- print("")
- print("Unknown entity, Omega Site")
- print("")
- print("")
- print("[E] Exit")
- local answer = io.read()
- goto continue1
- elseif answer == "2" then
- term.clear()
- print("︱ [ALERT] LOCKDOWN INITIATED ︱")
- print("")
- print("THIS IS NOT A DRILL, THIS IS NOT A DRILL, THIS IS NOT A DRILL")
- print("ALL SITES, COMMENCE Decontamination Procedure, COMMENCE LOCKDOWN.")
- print("READ REST OF MESSAGE WHEN COMPLETE!")
- print("")
- print("Omega site is unavailable, no one is answering. Lab 2 is the same.")
- print("Alpha site received a wormhole from Omega site but no one got through!.")
- print("We cannot reach them since High Command is also unavailable.")
- print("I have ordered an ALERT on all channels as proper procedure.")
- print("PLEASE RESPOND IF YOU ARE READING THIS!.")
- print("We also have a power problem at Alpha site, today we were supposed to receive a new ZPM.")
- print("At limited usage we should be good for another month, but after that we need to evacuate.")
- print("Since High Command is not available we cannot use our stargate, the Iris code is encrypted.")
- print("RESPOND IMMEDIATELY if receiving this message!.")
- print("")
- print("Rosewood, Head of Security, Alpha Site")
- print("")
- print("")
- print("[E] Exit")
- local answer = io.read()
- goto continue1
- elseif answer == "3" then
- term.clear()
- print("︱ [Lab 1] Missing Shipment ︱")
- print("")
- print("Im reaching you since i cant get a hold of Lab 2 myself, my security clearence isnt that high.")
- print("We were supposed to receive a shipment today but it never came. It was supposed to be delivered through the gate.")
- print("It does not say what it even is, so you can imagine my frustration.")
- print("Let me know if you find it, i will report this incident to my higher ups, you should report it to High Command.")
- print("")
- print("Jack, Shipment officer, Lab 1")
- print("")
- print("")
- print("[E] Exit")
- local answer = io.read()
- goto continue1
- elseif answer == "4" then
- term.clear()
- print("︱ [Lab 2] Lab results ︱")
- print("")
- print("We have dubbed it Alvin, from alvin and the chipmunks!")
- print("Alvin has exceeded our expectations, he (or it rather) is a perfect creature. Able to adapt and reform his body at will.")
- print("We have feeded it live chipmunks and it immediately assumed its form as one! Before devouring them.")
- print("It has now grown, its the size of a human. Although i doubt it has the intelligence of one.")
- print("It also has this weird effect on life around it, it kinda dies, and reanimates into something different.")
- print("We had to increase the security zone around its holding area, my plants were dying because of it.")
- print("We will need to move it in the near future, to a more secure facility.")
- print("I hear Lab 1 is getting a 20 billion dollar funding this year, lucky them.")
- print("Let High Command know i will be terminating the rest of the eggs also, they have begun to smell.")
- print("Oh and that Lab 1 can take care of Alvin.")
- print("")
- print("Doctor Greywall, Lab 2")
- print("")
- print("")
- print("[E] Exit")
- local answer = io.read()
- goto continue1
- elseif answer == "5" then
- term.clear()
- print("︱ [Omega] Iris installed ︱")
- print("")
- print("As per requested the Iris is now operational, although we are abit sceptical that the code is classified.")
- print("What if the settlers have family to visit?")
- print("Also it will become harder to receive supply, High command needs to approve everytime so they can shutdown the Iris!")
- print("Please forward these issues to High Command, its important for us.")
- print("We have also been seeing thing here, things in the dark. Im not the only one.")
- print("David saw a GIANT spider yesterday, looked like it could eat a cat!.")
- print("")
- print("Bryan Haddoc, Omega Site")
- print("")
- print("")
- print("[E] Exit")
- local answer = io.read()
- goto continue1
- elseif answer == "6" then
- term.clear()
- print("︱ [High cmd] Increased activity READ ME︱")
- print("")
- print("High Command has finished its assessment around the Omega site, new security measures are to be taken.")
- print("The local fauna has been increasing its hostility towards the site, where as before it was only curious of us, it is now our belief it has grown more hostile.")
- print("No doubt due to the experiments from Doctor Greywall in Lab 2.")
- print("An Iris to the gate at Omega site is to be installed at once! New intel suggests that there is currently a large scale operation")
- print("underway intended to sabotage the site, possibly even a takeover. Secure the gate, then take care of the wildlife surrounding the Omega site.")
- print("We dont want any surprises. Make sure that the Iris gate code is ONLY known by High Command.")
- print("")
- print("The settlements beyond Omega is also now at greater risk.")
- print("Until we have a greater understanding of the local fauna, NO personnel is allowed to leave the Omega site.")
- print("The settlers can protect themselves, they are all armed after all.")
- print("")
- print("Secretary General Coldwell, HC")
- print("")
- print("")
- print("[E] Exit")
- local answer = io.read()
- goto continue1
- elseif answer == "7" then
- term.clear()
- print("︱ [Lab 2] Eggsacks ︱")
- print("")
- print("The eggsacks found on the planet nibiru have produced results.")
- print("We have managed to create a hybrid of a vein floater along with local fauna found on the Omega site.")
- print("So far it has adapted to everything we have thrown at it,")
- print("Lava, shotguns, electrocutions, it seems to handle it all.")
- print("The staff is beginning to wonder what we should do if it breaks out.")
- print("Not to worry, the lab is set to blow with a 100 Megaton warhead if it does, but i wont tell them that.")
- print("Also it has begun laying eggs on its own, expect more results sooner now rather than later.")
- print("")
- print("Doctor Greywall, Lab 2")
- print("")
- print("")
- print("[E] Exit")
- local answer = io.read()
- goto continue1
- elseif answer == "e" or answer == "E" then
- else
- goto continue1
- end
- end
- -- Function to send messages
- local function send_message()
- ::continue1::
- term.clear()
- print("Pick receiver")
- print("[1] High Command")
- print("[2] Laboratory 1")
- print("[3] Laboratory 2")
- print("[4] Omega Site")
- print("[E] Exit")
- local answer = io.read()
- if answer == "1" then
- send_to = "High Command"
- term.clear()
- print("High Command Confirmed, please type the subject of your message and press enter")
- print("")
- local header = io.read()
- term.clear()
- print("Subject: " .. header)
- print("")
- print("Please type your message")
- print("")
- local message = io.read()
- term.clear()
- print("From: " .. Local_Name)
- print("Subject: " .. header)
- print("Message: " .. message)
- print("")
- print("Do you want to send this message to ".. send_to"?")
- print("Y/n")
- local answer = io.read()
- if answer == "Y" or answer == "y" then
- send_command(send_to, message, header)
- end
- term.clear()
- goto continue1
- elseif answer == "2" then
- send_to = "Laboratory 1"
- term.clear()
- print("Laboratory 1 Confirmed, please type the subject of your message and press enter")
- print("")
- local header = io.read()
- term.clear()
- print("Subject: " .. header)
- print("")
- print("Please type your message")
- print("")
- local message = io.read()
- term.clear()
- print("From: " .. Local_Name)
- print("Subject: " .. header)
- print("Message: " .. message)
- print("")
- print("Do you want to send this message to ".. send_to"?")
- print("Y/n")
- local answer = io.read()
- if answer == "Y" or answer == "y" then
- send_command(send_to, message, header)
- end
- term.clear()
- goto continue1
- elseif answer == "3" then
- send_to = "Laboratory 2"
- term.clear()
- print("Laboratory 2 Confirmed, please type the subject of your message and press enter")
- print("")
- local header = io.read()
- term.clear()
- print("Subject: " .. header)
- print("")
- print("Please type your message")
- print("")
- local message = io.read()
- term.clear()
- print("From: " .. Local_Name)
- print("Subject: " .. header)
- print("Message: " .. message)
- print("")
- print("Do you want to send this message to ".. send_to"?")
- print("Y/n")
- local answer = io.read()
- if answer == "Y" or answer == "y" then
- send_command(send_to, message, header)
- end
- term.clear()
- goto continue1
- elseif answer == "4" then
- send_to = "Omega Site"
- term.clear()
- print("Omega Site Confirmed, please type the subject of your message and press enter.")
- print("")
- local header = io.read()
- term.clear()
- print("Subject: " .. header)
- print("")
- print("Please type your message")
- print("")
- local message = io.read()
- term.clear()
- print("From: " .. Local_Name)
- print("Subject: " .. header)
- print("Message: " .. message)
- print("")
- print("Do you want to send this message to ".. send_to"?")
- print("Y/n")
- local answer = io.read()
- if answer == "Y" or answer == "y" then
- send_command(send_to, message, header)
- end
- term.clear()
- goto continue1
- elseif answer == "e" or answer == "E" then
- else
- goto continue1
- end
- end
- local function handle_modem_message(_, _, from, port, _, message, data)
- if port == 123 then
- if message == "error" then
- print("")
- print("[ERROR] " .. data)
- elseif message == "sent_message" then
- print("Sent message to " .. data)
- elseif message == "new_message" then
- local message_data = serialization.unserialize(data)
- if message_data.timestamp ~= lastMessageId then
- lastMessageId = message_data.timestamp
- print("")
- print("New message received from " .. message_data.from)
- print("Subject: " .. message_data.shrt .. message_data.header)
- print("Message: " .. message_data.message)
- print("User: " .. message_data.user)
- end
- end
- end
- end
- if reds.getBundledOutput(sides.bottom, colors.black) > 0 then
- reds.setBundledOutput(sides.bottom, colors.black, 0)
- end
- -- Keyboard Input Listener
- local function key_listener(_, _, char, code, playerName)
- local key = string.char(char)
- user = playerName
- event.ignore("key_down", key_listener)
- if key == "u" then
- term.clear()
- print("Connecting to central network...")
- os.sleep(3)
- print("[ERROR] No connection")
- os.sleep(0.5)
- print("[ERROR] Diagnosing...")
- os.sleep(3)
- print("[ERROR] Receiver [OFFLINE]")
- print("[✔] Transmitter [ONLINE]")
- print("[⚠] Can not receive orders/messages")
- print("[⚠] ONLY Transmit!")
- print("")
- print("Please follow standard Emergency Procedures")
- os.sleep(8)
- draw_ui()
- elseif key == "d" then
- if decon then
- print("Cannot stop Decontamination Procedure")
- elseif not decon then
- decon = not decon
- draw_ui()
- debug_card.runCommand("/effect @e[x=15019,y=40,z=12603,dx=57,dy=13,dz=57] minecraft:poison 10 3")
- os.sleep(10)
- decon = not decon
- draw_ui()
- print("Decontamination Procedure Complete!")
- end
- elseif key == "q" then
- reds.setBundledOutput(sides.bottom, colors.black, 255)
- draw_ui()
- print("")
- print("Dialing Omega Site!")
- os.sleep(2)
- reds.setBundledOutput(sides.bottom, colors.black, 0)
- elseif code == 57 then
- if beacon then
- print("Confirm Beacon Shutdown")
- print("Y/n")
- local answer = io.read()
- if answer == "y" or answer == "Y" then
- beacon = not beacon
- print("Confirmed")
- os.sleep(3)
- draw_ui()
- else
- print("Aborted!")
- os.sleep(3)
- draw_ui()
- end
- elseif not beacon then
- beacon = not beacon
- draw_ui()
- print("Emergency Beacon Online!")
- end
- elseif key == "m" then
- ::continue::
- draw_ui_messages()
- local answer = io.read()
- if answer == "r" or answer == "R" then
- read_message()
- goto continue
- elseif answer == "s" or answer == "S" then
- send_message()
- goto continue
- elseif answer == "e" or answer == "E" then
- draw_ui()
- else
- goto continue
- end
- end
- event.listen("key_down", key_listener)
- end
- draw_ui()
- messages = event.listen("modem_message", handle_modem_message)
- event.listen("key_down", key_listener)
- while running do
- os.sleep(0.5)
- end
- os.sleep(1)
- os.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement