Advertisement
samuelask

Omega Site

Apr 12th, 2025 (edited)
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 23.21 KB | None | 0 0
  1. -- Script for Bunker Control
  2. local component = require("component")
  3. local thread = require("thread")
  4. local event = require("event")
  5. local term = require("term")
  6. local serialization = require("serialization")
  7. local sides = require("sides")
  8. local colors = require("colors")
  9. local modem = component.modem
  10. local gpu = component.gpu
  11. local sg = component.stargate
  12. local zpm = component.zpmhub
  13. local tunnel = component.tunnel
  14. local reds = component.redstone
  15. local data = component.data
  16. local keyboard = require("keyboard")
  17. local lastMessageId = nil
  18. IDC = "1337"
  19. user = ""
  20. Local_Name = "Omega Site"
  21. Short_Name = "[Omega]"
  22. running = true
  23. tesla = false
  24. lights = false
  25. iris_status = false
  26. charging = false
  27. lockdown = true
  28. dialingyes = false
  29. -- Configuration
  30. beacon = true
  31. modem.open(123)
  32. local screenWidth, screenHeight = gpu.getResolution()
  33.  
  34. local default_messages = {
  35.   {
  36.     from = "Omega Site",
  37.     shrt = "[Omega]",
  38.     user = "Unknown entity",
  39.     to = Local_Name,
  40.     header = "ComE",
  41.     message = "Join us, we lvie in hramony, the msnoetrs are gone, we cannot aecscc your wold,\nyou will cmoe to ouesr, cmoe cmoe, Alvin missse you all",
  42.     timestamp = 7
  43.   },
  44.   {
  45.     from = "Alpha Site",
  46.     shrt = "[ALERT]",
  47.     user = "Rosewood, Head of Security",
  48.     to = Local_Name,
  49.     header = "LOCKDOWN INITIATED",
  50.     message = "THIS IS NOT A DRILL, THIS IS NOT A DRILL, THIS IS NOT A DRILL\nALL SITES, COMMENCE Decontamination Procedure, COMMENCE LOCKDOWN.\nREAD REST OF MESSAGE WHEN COMPLETE!\n\nOmega site is unavailable, no one is answering. Lab 2 is the same.\nAlpha site received a wormhole from Omega site but no one got through!.\nWe cannot reach them since High Command is also unavailable.\nI have ordered an ALERT on all channels as proper procedure.\nPLEASE RESPOND IF YOU ARE READING THIS!.\nWe also have a power problem at Alpha site, today we were supposed to receive a new ZPM.\nAt limited usage we should be good for another month, but after that we need to evacuate.\nSince High Command is not available we cannot use our stargate, the Iris code is encrypted.\nRESPOND IMMEDIATELY if receiving this message!.",
  51.     timestamp = 6
  52.   },
  53.   {
  54.     from = "Laboratory 1",
  55.     shrt = "[Lab 1]",
  56.     user = "Jack, Shipment officer",
  57.     to = Local_Name,
  58.     header = "Missing Shipment",
  59.     message = "Im reaching you since i cant get a hold of Lab 2 myself, my security clearence isnt that high.\nWe were supposed to receive a shipment today but it never came. It was supposed to be delivered through the gate.\nIt does not say what it even is, so you can imagine my frustration.\nLet me know if you find it, i will report this incident to my higher ups, you should report it to High Command.",
  60.     timestamp = 5
  61.   },
  62.   {
  63.     from = "Laboratory 2",
  64.     shrt = "[Lab 2]",
  65.     user = "Doctor Greywall",
  66.     to = Local_Name,
  67.     header = "Lab results",
  68.     message = "We have dubbed it Alvin, from alvin and the chipmunks!\nAlvin has exceeded our expectations, he (or it rather) is a perfect creature. Able to adapt and reform his body at will.\nWe have feeded it live chipmunks and it immediately assumed its form as one! Before devouring them.\nIt has now grown, its the size of a human. Although i doubt it has the intelligence of one.\nIt also has this weird effect on life around it, it kinda dies, and reanimates into something different.\nWe had to increase the security zone around its holding area, my plants were dying because of it.\nWe will need to move it in the near future, to a more secure facility.\nI hear Lab 1 is getting a 20 billion dollar funding this year, lucky them.\nLet High Command know i will be terminating the rest of the eggs also, they have begun to smell.\nOh and that Lab 1 can take care of Alvin.",
  69.     timestamp = 4
  70.   },
  71.   {
  72.     from = "Omega Site",
  73.     shrt = "[Omega]",
  74.     user = "Bryan Haddoc",
  75.     to = Local_Name,
  76.     header = "Iris installed",
  77.     message = "As per requested the Iris is now operational, although we are abit sceptical that the code is classified.\nWhat if the settlers have family to visit?\nAlso it will become harder to receive supply, High command needs to approve everytime so they can shutdown the Iris!\nPlease forward these issues to High Command, its important for us.\nWe have also been seeing things here, things in the dark. I'm not the only one.\nDavid saw a GIANT spider yesterday, looked like it could eat a cat!.",
  78.     timestamp = 3
  79.   },
  80.   {
  81.     from = "High Command",
  82.     shrt = "[High cmd]",
  83.     user = "Secretary General Coldwell",
  84.     to = Local_Name,
  85.     header = "Increased activity READ ME",
  86.     message = "High Command has finished its assessment around the Omega site, new security measures are to be taken.\nThe 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.\nNo doubt due to the experiments from Doctor Greywall in Lab 2.\nAn Iris to the gate at Omega site is to be installed at once! New intel suggests that there is currently a large scale operation\nunderway intended to sabotage the site, possibly even a takeover. Secure the gate, then take care of the wildlife surrounding the Omega site.\nWe dont want any surprises. Make sure that the Iris gate code is ONLY known by High Command.\n\nThe settlements beyond Omega is also now at greater risk.\nUntil we have a greater understanding of the local fauna, NO personnel is allowed to leave the Omega site.\nThe settlers can protect themselves, they are all armed after all.",
  87.     timestamp = 2
  88.   },
  89.   {
  90.     from = "Laboratory 2",
  91.     shrt = "[Lab 2]",
  92.     user = "Doctor Greywall",
  93.     to = Local_Name,
  94.     header = "Eggsacks",
  95.     message = "The eggsacks found on the planet Nibiru have produced results.\nWe have managed to create a hybrid of a vein floater along with local fauna found on the Omega site.\nSo far it has adapted to everything we have thrown at it,\nLava, shotguns, electrocutions, it seems to handle it all.\nThe staff is beginning to wonder what we should do if it breaks out.\nNot to worry, the lab is set to blow with a 100 Megaton warhead if it does, but I won't tell them that.\nAlso it has begun laying eggs on its own, expect more results sooner now rather than later.",
  96.     timestamp = 1
  97.   },
  98. }
  99.  
  100. function drawMessageBox(message_data)
  101.   local screenWidth, _ = gpu.getResolution()
  102.  
  103.   -- Prepare message lines
  104.   local lines = {
  105.     "New message received from " .. message_data.from,
  106.     "Subject: " .. message_data.shrt .. " " .. message_data.header,
  107.     "Message: " .. message_data.message,
  108.     "User: " .. message_data.user
  109.   }
  110.  
  111.   -- Determine max line length
  112.   local maxLength = 0
  113.   for _, line in ipairs(lines) do
  114.     if #line > maxLength then
  115.       maxLength = #line
  116.     end
  117.   end
  118.  
  119.   -- Box styling
  120.   local padding = 2
  121.   local boxWidth = maxLength + padding * 2
  122.   local boxHeight = #lines + 2 -- top + bottom border
  123.  
  124.   local startX = screenWidth - boxWidth + 1
  125.   local startY = 1
  126.  
  127.   -- Draw top border
  128.   gpu.set(startX, startY, "┌" .. string.rep("─", boxWidth - 2) .. "┐")
  129.  
  130.   -- Draw box sides and empty space
  131.   for i = 1, boxHeight - 2 do
  132.     gpu.set(startX, startY + i, "│" .. string.rep(" ", boxWidth - 2) .. "│")
  133.   end
  134.  
  135.   -- Draw bottom border
  136.   gpu.set(startX, startY + boxHeight - 1, "└" .. string.rep("─", boxWidth - 2) .. "┘")
  137.  
  138.   -- Write text inside the box
  139.   for i, line in ipairs(lines) do
  140.     gpu.set(startX + padding, startY + i, line)
  141.   end
  142. end
  143.  
  144. -- UI Drawing Function
  145. local function draw_ui()
  146.     term.clear()
  147.     print("Omega Site Control")
  148.     print("[SPACE] Toggle Emergency Beacon [" .. (beacon and "ON" or "OFF") .. "]")
  149.     print("[D] Toggle Perimeter Defense[" .. (tesla and "ON" or "OFF") .. "]")
  150.     print("[L] Toggle Perimeter Lights[" .. (lights and "ON" or "OFF") .. "]")
  151.     print("[U] Update orders from high command")
  152.     print("[M] Messages")
  153.     print("[C] Charge Gate")
  154.     print("[Q] Dialing Menu")
  155. end
  156.  
  157. -- UI Drawing Function messages
  158. local function draw_ui_messages()
  159.     term.clear()
  160.     print("Messages")
  161.     print("[R] Read messages")
  162.     print("[S] Send message")
  163.     print("[E] Exit")
  164. end
  165.  
  166. -- UI Drawing Function dialing
  167. local function draw_ui_dialing()
  168.     term.clear()
  169.     print("Dialing Menu")
  170.     if not dialingyes then
  171.         if lockdown then
  172.             print("[WARNING] Lockdown in effect, iris will turn on when dialing out!")
  173.             print("[L] Disable Lockdown")
  174.         elseif not lockdown then
  175.             print("[L] Enable Lockdown")
  176.         end
  177.         print("[1] Dial Epsilon Site")
  178.         print("[2] Dial Laboratory 1")
  179.         print("[3] Dial Laboratory 2")
  180.         print("[4] Dial Alpha Site")
  181.         print("[5] Dial High Command")
  182.         print("[E] Exit")
  183.     elseif dialingyes then
  184.         print("Dialing: ") -- Fix later, in the middle of the screen and an abort function
  185.         print("[E] Exit")
  186.     end
  187. end
  188. local function is_floppy_valid()
  189.  
  190.   local privFile = io.open("/rPrivate.key", "r")
  191.   if not privFile then
  192.     print("[✘] Missing /rPrivate.key!")
  193.     return false
  194.   end
  195.  
  196.   local privSerialized = privFile:read("*a")
  197.   privFile:close()
  198.  
  199.   local rPrivate = data.deserializeKey(serialization.unserialize(privSerialized), "ec-private")
  200.  
  201.   for address in component.list("disk_drive") do
  202.     local drive = component.proxy(address)
  203.  
  204.     local ok, present = pcall(function() return not drive.isEmpty() end)
  205.     if not ok then
  206.       print("[DEBUG] Error calling isEmpty(): " .. tostring(present))
  207.     elseif present then
  208.  
  209.       local fsAddress = drive.media()
  210.       if fsAddress then
  211.         local fs = component.proxy(fsAddress)
  212.  
  213.         if fs.exists("/key.dat") then
  214.           local f = fs.open("/key.dat", "r")
  215.           if f then
  216.             local content = fs.read(f, math.huge)
  217.             fs.close(f)
  218.  
  219.             if content then
  220.               local packet = serialization.unserialize(content)
  221.               local sPublic = data.deserializeKey(serialization.unserialize(packet.header.sPublic), "ec-public")
  222.               local iv = packet.header.iv
  223.               local encryptedData = packet.data
  224.  
  225.               local sharedKey = data.md5(data.ecdh(rPrivate, sPublic))
  226.               local decrypted = data.decrypt(encryptedData, sharedKey, iv)
  227.  
  228.               if decrypted then
  229.                 local result = serialization.unserialize(decrypted)
  230.                 if result == "supersecretpassword" then
  231.                   return true
  232.                 else
  233.                 end
  234.               else
  235.               end
  236.             else
  237.             end
  238.           else
  239.           end
  240.         else
  241.         end
  242.       else
  243.       end
  244.     else
  245.     end
  246.   end
  247.   return false
  248. end
  249. local function decryptkey()
  250.   term.clear()
  251.   print("HIGH CMD SECURITY KEY NEEDED")
  252.   print("Place the Floppy Disk Security key inside the Disk Drive")
  253.   print("Press [E] to exit.")
  254.   local animY = 6 -- Row to draw the blinking text
  255.   while true do
  256.     local visible = math.floor(os.clock() * 1.5) % 2 == 0
  257.     local msg = "Waiting for Security Key..."
  258.     local x = math.floor((screenWidth - #msg) / 2)
  259.     if visible then
  260.         gpu.set(x, animY, msg)
  261.     else
  262.         gpu.set(x, animY, string.rep(" ", #msg))
  263.     end
  264.     if is_floppy_valid() then
  265.       print("\n[✔] Valid Security Key Detected.")
  266.       lockdown = false
  267.       os.sleep(1)
  268.       return true
  269.     end
  270.  
  271.     local ev, _, _, code = event.pull(0.1, "key_down")
  272.     if ev == "key_down" then
  273.       print("You pressed key ID:", code)
  274.       if code == keyboard.keys.e then
  275.         print("[✖] Authorization Aborted.")
  276.         return false
  277.       end
  278.     end
  279.     os.sleep(0.1)
  280.   end
  281. end
  282. -- Function to send commands
  283. local function send_command(address, value, header)
  284.  
  285.   local data = {
  286.     from = Local_Name,
  287.     shrt = Short_Name,
  288.     user = user,
  289.     to = address,
  290.     header = header,
  291.     message = value,
  292.     timestamp = os.time()
  293.   }
  294.     local serialized_data = serialization.serialize(data)
  295.     tunnel.send(serialized_data)
  296. end
  297. local function handle_incomingwh()
  298.     if not iris_status then
  299.         iris_status = true
  300.         if not charging then
  301.             zpm.toggleSlots()
  302.         end
  303.         sg.toggleIris()
  304.         print("INCOMING WORMHOLE!.")
  305.     end
  306. end
  307. local function handle_closingwh()
  308.     if iris_status then
  309.         sg.toggleIris()
  310.         zpm.toggleSlots()
  311.         iris_status = false
  312.     end
  313. end
  314. -- Function to read messages
  315. local function read_message()
  316.   local path = "/messages.dat"
  317.   local file = io.open(path, "r")
  318.   if not file then
  319.     print("No messages found.")
  320.     os.sleep(2)
  321.     return
  322.   end
  323.  
  324.   local content = file:read("*a")
  325.   file:close()
  326.  
  327.   local messages = serialization.unserialize(content)
  328.  
  329.   if not messages or #messages == 0 then
  330.     print("Inbox empty.")
  331.     os.sleep(2)
  332.     return
  333.   end
  334.  
  335.   -- Sort by timestamp descending (newest first)
  336.   table.sort(messages, function(a, b)
  337.     return tonumber(a.timestamp) > tonumber(b.timestamp)
  338.   end)
  339.  
  340.   while true do
  341.     term.clear()
  342.     print("Inbox")
  343.     print("︱NEWEST︱")
  344.  
  345.     for i, msg in ipairs(messages) do
  346.       print(string.format("[%d] ︱ %s %s ︱", i, msg.shrt or "", msg.header or ""))
  347.     end
  348.  
  349.     print("︱OLDEST︱")
  350.     print("")
  351.     print("[E] Exit")
  352.     local answer = io.read()
  353.  
  354.     if answer == "e" or answer == "E" then
  355.       break
  356.     else
  357.       local index = tonumber(answer)
  358.       if index and messages[index] then
  359.         local msg = messages[index]
  360.         term.clear()
  361.         print(string.format("︱ %s %s ︱", msg.shrt or "", msg.header or ""))
  362.         print("")
  363.         print(msg.message or "")
  364.         print("")
  365.         print(msg.user or "Unknown sender")
  366.         print("")
  367.         print("[E] Exit")
  368.         local _ = io.read()
  369.       end
  370.     end
  371.   end
  372. end
  373.  
  374. -- Function to send messages
  375. local function send_message()
  376.     ::continue1::
  377.     term.clear()
  378.     print("Pick receiver")
  379.     print("[1] Epsilon Site")
  380.     print("[2] Laboratory 1")
  381.     print("[3] Laboratory 2")
  382.     print("[4] High Command")
  383.     print("[E] Exit")
  384.     local answer = io.read()
  385.     if answer == "1" then
  386.         send_to = "Epsilon Site"
  387.         print("Epsilon Site Confirmed, please type the subject of your message and press enter")
  388.         print("")
  389.         local header = io.read()
  390.         term.clear()
  391.         print("Subject: " .. header)
  392.         print("")
  393.         print("Please type your message")
  394.         print("")
  395.         local message = io.read()
  396.         term.clear()
  397.         print("From: " .. Local_Name)
  398.         print("Subject: " .. header)
  399.         print("Message: " .. message)
  400.         print("")
  401.         print("Do you want to send this message to ".. send_to .."?")
  402.         io.write("Y/n: ")
  403.         local answer = io.read()
  404.         if answer == "Y" or answer == "y" then
  405.             send_command(send_to, message, header)
  406.         end
  407.         term.clear()
  408.         goto continue1
  409.     elseif answer == "2" then
  410.         send_to = "Laboratory 1"
  411.         term.clear()
  412.         print("Laboratory 1 Confirmed, please type the subject of your message and press enter")
  413.         print("")
  414.         local header = io.read()
  415.         term.clear()
  416.         print("Subject: " .. header)
  417.         print("")
  418.         print("Please type your message")
  419.         print("")
  420.         local message = io.read()
  421.         term.clear()
  422.         print("From: " .. Local_Name)
  423.         print("Subject: " .. header)
  424.         print("Message: " .. message)
  425.         print("")
  426.         print("Do you want to send this message to ".. send_to .."?")
  427.         io.write("Y/n: ")
  428.         local answer = io.read()
  429.         if answer == "Y" or answer == "y" then
  430.             send_command(send_to, message, header)
  431.         end
  432.         term.clear()
  433.         goto continue1
  434.     elseif answer == "3" then
  435.         send_to = "Laboratory 2"
  436.         term.clear()
  437.         print("Laboratory 2 Confirmed, please type the subject of your message and press enter")
  438.         print("")
  439.         local header = io.read()
  440.         term.clear()
  441.         print("Subject: " .. header)
  442.         print("")
  443.         print("Please type your message")
  444.         print("")
  445.         local message = io.read()
  446.         term.clear()
  447.         print("From: " .. Local_Name)
  448.         print("Subject: " .. header)
  449.         print("Message: " .. message)
  450.         print("")
  451.         print("Do you want to send this message to ".. send_to .."?")
  452.         io.write("Y/n: ")
  453.         local answer = io.read()
  454.         if answer == "Y" or answer == "y" then
  455.             send_command(send_to, message, header)
  456.         end
  457.         term.clear()
  458.         goto continue1
  459.     elseif answer == "4" then
  460.         send_to = "High Command"
  461.         term.clear()
  462.         print("High Command Confirmed, please type the subject of your message and press enter.")
  463.         print("")
  464.         local header = io.read()
  465.         term.clear()
  466.         print("Subject: " .. header)
  467.         print("")
  468.         print("Please type your message")
  469.         print("")
  470.         local message = io.read()
  471.         term.clear()
  472.         print("From: " .. Local_Name)
  473.         print("Subject: " .. header)
  474.         print("Message: " .. message)
  475.         print("")
  476.         print("Do you want to send this message to ".. send_to .."?")
  477.         io.write("Y/n: ")
  478.         local answer = io.read()
  479.         if answer == "Y" or answer == "y" then
  480.             send_command(send_to, message, header)
  481.         end
  482.         term.clear()
  483.         goto continue1
  484.     elseif answer == "e" or answer == "E" then
  485.    
  486.     else
  487.         goto continue1
  488.     end
  489. end
  490. local function init_message_file()
  491.   local path = "/messages.dat"
  492.   local f = io.open(path, "r")
  493.   if not f then
  494.     -- Save default messages to file
  495.     local file = io.open(path, "w")
  496.     if file then
  497.       file:write(serialization.serialize(default_messages))
  498.       file:close()
  499.     end
  500.   else
  501.     f:close()
  502.   end
  503. end
  504. local function save_message(message_data)
  505.   local filepath = "/messages.dat"
  506.   local messages = {}
  507.  
  508.   -- Load existing messages if file exists
  509.   local file = io.open(filepath, "r")
  510.   if file then
  511.     local content = file:read("*a")
  512.     file:close()
  513.     if content and #content > 0 then
  514.       messages = serialization.unserialize(content) or {}
  515.     end
  516.   end
  517.  
  518.   -- Add new message
  519.   table.insert(messages, message_data)
  520.  
  521.   -- Sort by timestamp
  522.   table.sort(messages, function(a, b)
  523.     return a.timestamp < b.timestamp
  524.   end)
  525.  
  526.   -- Save updated messages back to file
  527.   file = io.open(filepath, "w")
  528.   if file then
  529.     file:write(serialization.serialize(messages))
  530.     file:close()
  531.   end
  532. end
  533. local function handle_modem_message(_, _, from, port, _, message, data)
  534.     if port == 123 or port == 0 then
  535.         if message == "error" then
  536.             print("")
  537.             print("[ERROR] " .. data)
  538.         elseif message == "sent_message" then
  539.             print("")
  540.             print("Sent message to " .. data)
  541.         elseif message == "new_message" then
  542.             local message_data = serialization.unserialize(data)
  543.             if message_data.timestamp ~= lastMessageId then
  544.                 lastMessageId = message_data.timestamp
  545.                 drawMessageBox(message_data)
  546.                 save_message(message_data)
  547.             end
  548.         elseif message == "code" then
  549.             if data == IDC then
  550.                 if iris_status then
  551.                     iris_status = false
  552.                     sg.toggleIris()
  553.                     zpm.toggleSlots()
  554.                 end
  555.             end
  556.         elseif message == "lockdown" then
  557.             lockdown = true
  558.         end
  559.     end
  560. end
  561. function drawChargingProgress()
  562.   local screenWidth, screenHeight = gpu.getResolution()
  563.   local label = "Charging Gate..."
  564.   local labelX = math.floor((screenWidth - #label) / 2) + 1
  565.   local labelY = math.floor(screenHeight / 2)
  566.  
  567.   -- Progress bar settings
  568.   local barWidth = 30
  569.   local barX = math.floor((screenWidth - barWidth) / 2) + 1
  570.   local barY = labelY + 2
  571.   local totalTime = 34 -- seconds
  572.   local updateRate = 0.1 -- how often to update in seconds
  573.   local steps = math.floor(totalTime / updateRate)
  574.  
  575.   -- Clear label and bar area
  576.   for i = 0, 3 do
  577.     gpu.set(1, labelY + i, string.rep(" ", screenWidth))
  578.   end
  579.  
  580.   -- Draw label
  581.   gpu.set(labelX, labelY, label)
  582.  
  583.   -- Progress bar loop
  584.   for i = 0, steps do
  585.  
  586.     if iris_status then
  587.     draw_ui()
  588.     term.setCursor(1, barY + 2)
  589.     print("[!] Charging aborted: Iris status triggered.")
  590.     return end
  591.  
  592.     local filled = math.floor((i / steps) * barWidth)
  593.     local empty = barWidth - filled
  594.     gpu.set(barX, barY, "[" .. string.rep("█", filled) .. string.rep(" ", empty) .. "]")
  595.     os.sleep(updateRate)
  596.   end
  597. end
  598. local function chargegate()
  599.     charging = true
  600.     zpm.toggleSlots()
  601.     drawChargingProgress()
  602.     if not iris_status then
  603.         zpm.toggleSlots()
  604.     end
  605.     charging = false
  606. end
  607. -- Keyboard Input Listener
  608. local function key_listener(_, _, char, code, playerName)
  609.     local key = string.char(char)
  610.     user = playerName
  611.     event.ignore("key_down", key_listener)
  612.     if key == "u" then
  613.             term.clear()
  614.             print("Connecting to central network...")
  615.             os.sleep(3)
  616.             print("[ERROR] No connection")
  617.             os.sleep(0.5)
  618.             print("[ERROR] Diagnosing...")
  619.             os.sleep(3)
  620.             print("[✔] Receiver [ONLINE]")
  621.             print("[✔] Transmitter [ONLINE]")
  622.             print("[ERROR] High Command blocked or not responding")
  623.             print("[⚠] Can not receive orders!")
  624.             print("")
  625.             print("Please follow standard Emergency Procedures")
  626.             os.sleep(8)
  627.             draw_ui()
  628.     elseif key == "d" then
  629.             if tesla then
  630.                 tesla = not tesla
  631.                 reds.setBundledOutput(sides.bottom, colors.yellow, 0)
  632.                 draw_ui()
  633.                 print("Turned Off Perimeter Defense")
  634.             elseif not tesla then
  635.                 tesla = not tesla
  636.                 reds.setBundledOutput(sides.bottom, colors.yellow, 255)
  637.                 draw_ui()
  638.                 print("Turned On Perimeter Defense")
  639.             end
  640.     elseif key == "l" then
  641.             if lights then
  642.                 lights = not lights
  643.                 reds.setBundledOutput(sides.bottom, colors.green, 255)
  644.                 draw_ui()
  645.                 print("Turned Off Perimeter Lights")
  646.             elseif not lights then
  647.                 lights = not lights
  648.                 reds.setBundledOutput(sides.bottom, colors.green, 0)
  649.                 draw_ui()
  650.                 print("Turned On Perimeter Lights")
  651.             end
  652.     elseif key == "q" then
  653.             ::continue3::
  654.             draw_ui_dialing()
  655.             local answer = io.read()
  656.             if answer == "l" or answer == "L" then
  657.                 if lockdown then
  658.                     decryptkey()
  659.                 elseif not lockdown then
  660.                     lockdown = true
  661.                 end
  662.                 goto continue3
  663.             elseif answer == "1" then
  664.                 send_message()
  665.                 goto continue3
  666.             elseif answer == "2" then
  667.                 send_message()
  668.                 goto continue3
  669.             elseif answer == "3" then
  670.                 send_message()
  671.                 goto continue3
  672.             elseif answer == "4" then
  673.                 send_message()
  674.                 goto continue3
  675.             elseif answer == "5" then
  676.                 send_message()
  677.                 goto continue3
  678.             elseif answer == "e" or answer == "E" then
  679.                 draw_ui()
  680.             else
  681.                 goto continue3
  682.             end        
  683.     elseif code == 57 then
  684.         if beacon then
  685.             print("Confirm Beacon Shutdown")
  686.             io.write("Y/n: ")
  687.             local answer = io.read()
  688.             if answer == "y" or answer == "Y" then
  689.                 beacon = not beacon
  690.                 print("Confirmed")
  691.                 os.sleep(3)
  692.                 draw_ui()
  693.             else
  694.                 print("Aborted!")
  695.                 os.sleep(3)
  696.                 draw_ui()
  697.             end
  698.         elseif not beacon then
  699.             beacon = not beacon
  700.             draw_ui()
  701.             print("Emergency Beacon Online!")
  702.            
  703.         end
  704.     elseif key == "m" then
  705.         ::continue::
  706.         draw_ui_messages()
  707.         local answer = io.read()
  708.         if answer == "r" or answer == "R" then
  709.             read_message()
  710.             goto continue
  711.         elseif answer == "s" or answer == "S" then
  712.             send_message()
  713.             goto continue
  714.         elseif answer == "e" or answer == "E" then
  715.             draw_ui()
  716.         else
  717.             goto continue
  718.         end
  719.     elseif key == "c" then
  720.         if iris_status then
  721.             print("[!] Cannot Charge when Iris is up!.")
  722.         elseif not iris_status then
  723.             chargegate()
  724.             draw_ui()
  725.         end
  726.     end
  727.     event.listen("key_down", key_listener)
  728. end
  729. if reds.getBundledOutput(sides.bottom, colors.yellow) > 0 then
  730.     tesla = true
  731. end
  732. if reds.getBundledOutput(sides.bottom, colors.green) < 1 then
  733.     lights = true
  734. end
  735. draw_ui()
  736. init_message_file()
  737. messages = event.listen("modem_message", handle_modem_message)
  738. incomingwh = event.listen("stargate_incoming_wormhole", handle_incomingwh)
  739. closingwh = event.listen("stargate_wormhole_closed_fully", handle_closingwh)
  740. event.listen("key_down", key_listener)
  741.  
  742. while running do
  743.     os.sleep(0.5)
  744. end
  745.  
  746. os.sleep(1)
  747. os.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement