View difference between Paste ID: Y37RTBbv and 29citfmF
SHOW: | | - or go back to the newest paste.
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-
        interface.engageSymbol(address[chevron])
15+
        
16-
		os.sleep(0.5)
16+
        local symbol = address[chevron]
17-
		print("Symbol Engaged: " .. address[chevron])
17+
        
18
        interface.engageSymbol(symbol)
19
    end 
20
end
21-
-- Define destinations with labels and addresses
21+
22-
local destinations = {
22+
23-
    {label = "Citadel", 		address = {14,6,10,2,20,33,23,17,0}},
23+
local modem = peripheral.wrap("top") or error("No modem attached", 0)
24-
    {label = "A-Base", 			address = {14,26,30,21,35,2,18,22,0}},
24+
modem.open(12) -- Open 43 so we can receive replies
25-
    {label = "Spawn", 			address = {18,2,12,20,31,5,28,25,0}},
25+
26-
    {label = "Nether", 			address = {28,25,14,19,18,26,32,31,0}},
26+
-- And wait for a reply
27-
    {label = "Stripmine", 		address = {32,9,1,12,31,10,24,23,0}},
27+
local event, side, channel, replyChannel, message, distance
28-
    {label = "Abydos", 			address = {26,6,14,31,11,29,0}},
28+
repeat
29-
    {label = "The End", 		address = {14,30,6,13,17,23,0}},
29+
    event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
30-
    {label = "Cavum Tenebrae", 	address = {18,7,3,36,25,15,0}},
30+
until channel == 12
31-
    {label = "Chulak", 			address = {8,1,22,14,36,19,0}},
31+
32-
    {label = "Backup", 			address = {15,5,4,30,6,35,19,20,0}},
32+
-- Process the received message based on its content
33-
    {label = "Otherside", 		address = {21,38,36,34,35,37,0}}
33+
if message == "Output" then
34
    print("Activating Gate...")
35-
}
35+
    modem.transmit(46, 12, "Activating Gate...")
36
	dial({22,12,31,16,26,18,2,8,0})
37-
clearScreen()
37+
	os.sleep(7)
38
    
39-
-- Print available destinations
39+
40-
print("Available destinations:")
40+
    repeat
41-
for i, dest in ipairs(destinations) do
41+
        os.sleep(0.1)
42-
    print(i .. " = " .. dest.label)
42+
    until interface.isStargateConnected() == true
43
    print("Gate Activated...")
44
	
45-
-- Get user input
45+
    print("Comencing Drop...")
46-
print("Select a destination:")
46+
    redstone.setOutput("front", true)
47-
local input = tonumber(io.read()) -- Read input as number
47+
48
    os.sleep(10)
49-
-- Dial the selected destination if input is valid
49+
50-
if input and input >= 1 and input <= #destinations then
50+
    print("Stoping Drop...")
51-
	clearScreen()
51+
    redstone.setOutput("front", false)
52-
	print("Dialing...")
52+
    
53-
    dial(destinations[input].address) -- Dial the address of the selected destination
53+
54-
elseif input == 404 then
54+
55-
	dial({15,5,4,30,6,35,19,20,0})
55+
print("Closing Gate...")
56-
    print("Error...")
56+
os.sleep(3)
57-
else
57+
58-
    print("Invalid input")
58+
shell.run("CloseGate")
59
os.sleep(3)
60
os.reboot()