Advertisement
oswald_the_void

Midway Dialing Program

May 3rd, 2025
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --this is a midway program ment to go into the end
  2. local gate_1 = peripheral.wrap("crystal_interface_27") --modify to the milkyway gate in the end
  3. local gate_2 = peripheral.wrap("crystal_interface_26") --modify to the pegasus gate in the end
  4. --since only you know how many interfaces you used in total
  5.  
  6. local lantea_address = {29,5,17,34,6,12,0} -- Replace with Lantea
  7. local return_address = {27,25,4,35,10,28,0} -- Replace with return or home
  8.  
  9. local last_feedback_1 = nil
  10. local last_feedback_2 = nil
  11.  
  12. -- Function to dial a gate
  13. local function dialAddress(gate, address)
  14.     print("Dialing: " .. table.concat(address, "-"))
  15.     for _, symbol in ipairs(address) do
  16.         gate.engageSymbol(symbol)
  17.         os.sleep(0.5)
  18.     end
  19. end
  20.  
  21. local feedback = 0
  22. if gate_2 then
  23.     local ok, result
  24.     if ok then
  25.         feedback = result
  26.     else
  27.         print("Pegasus gate feedback error:", result)
  28.     end
  29. else
  30.     print("Pegasus gate is nil during check.")
  31. end
  32.  
  33. -- Function to check and return new feedback
  34. local function checkNewFeedback(gate, last_feedback)
  35.     local feedback = gate.getRecentFeedback()
  36.     if feedback ~= last_feedback then
  37.         return feedback
  38.     end
  39.     return nil
  40. end
  41.  
  42. print("Midway relay system running...")
  43.  
  44. while true do
  45.     local feedback_1 = checkNewFeedback(gate_1, last_feedback_1)
  46.     local feedback_2 = checkNewFeedback(gate_2, last_feedback_2)
  47.  
  48.     if feedback_1 then
  49.         last_feedback_1 = feedback_1
  50.         print("Gate 1 Feedback:", feedback_1)
  51.  
  52.         if feedback_1 == -30 then
  53.             print("Incoming wormhole detected on Gate 1. Dialing Lantea from Gate 2...")
  54.             dialAddress(gate_2, lantea_address)
  55.         elseif feedback_1 == 7 then
  56.             print("Gate 1 disconnected.")
  57.         end
  58.     end
  59.  
  60.     if feedback_2 then
  61.         last_feedback_2 = feedback_2
  62.         print("Gate 2 Feedback:", feedback_2)
  63.  
  64.         if feedback_2 == -30 then
  65.             print("Incoming wormhole detected on Gate 2. Dialing return address from Gate 1...")
  66.             dialAddress(gate_1, return_address)
  67.         elseif feedback_2 == 7 then
  68.             print("Gate 2 disconnected.")
  69.         end
  70.     end
  71.  
  72.     os.sleep(0.2)
  73. end
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement