Advertisement
Alexr360

Stargate Cargo Control

Apr 3rd, 2024 (edited)
829
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function clearScreen()
  2.   term.clear()
  3.   term.setCursorPos(1, 1)
  4. end
  5.  
  6. function dial(address)
  7.     interface = peripheral.find("crystal_interface")
  8.    
  9.     local addressLength = #address
  10.    
  11.     local start = interface.getChevronsEngaged() + 1
  12.    
  13.     for chevron = start,addressLength,1
  14.     do
  15.        
  16.         local symbol = address[chevron]
  17.        
  18.         interface.engageSymbol(symbol)
  19.     end
  20. end
  21.  
  22.  
  23. local modem = peripheral.wrap("top") or error("No modem attached", 0)
  24. modem.open(12) -- Open 43 so we can receive replies
  25.  
  26. -- And wait for a reply
  27. local event, side, channel, replyChannel, message, distance
  28. repeat
  29.     event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  30. until channel == 12
  31.  
  32. -- Process the received message based on its content
  33. if message == "Output" then
  34.     print("Activating Gate...")
  35.     modem.transmit(46, 12, "Activating Gate...")
  36.     dial({22,12,31,16,26,18,2,8,0})
  37.     os.sleep(7)
  38.    
  39.     interface = peripheral.find("crystal_interface")
  40.     repeat
  41.         os.sleep(0.1)
  42.     until interface.isStargateConnected() == true
  43.     print("Gate Activated...")
  44.    
  45.     print("Comencing Drop...")
  46.     redstone.setOutput("front", true)
  47.  
  48.     os.sleep(10)
  49.  
  50.     print("Stoping Drop...")
  51.     redstone.setOutput("front", false)
  52.    
  53. end
  54.  
  55. print("Closing Gate...")
  56. os.sleep(3)
  57.  
  58. shell.run("CloseGate")
  59. os.sleep(3)
  60. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement