Skip to content

Instantly share code, notes, and snippets.

@MrJake222
Last active June 11, 2021 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrJake222/c4f8eab50dd91e8b133a8d51616d7eb7 to your computer and use it in GitHub Desktop.
Save MrJake222/c4f8eab50dd91e8b133a8d51616d7eb7 to your computer and use it in GitHub Desktop.
Simple dialing program for AUNIS
address = {"Aries", "Auriga", "Crater", "Andromeda", "Aquarius", "Leo Minor", "Point of Origin"}
c = require("component")
event = require("event")
os = require("os")
sg = c.stargate
print("Dialing")
for i,v in ipairs(address) do print(i,v) end
print()
loop = true
function dialNext(dialed)
glyph = address[dialed + 1]
print("Engaging "..glyph.."... ")
sg.engageSymbol(glyph)
end
function cancelEvents()
event.cancel(eventEngaged)
event.cancel(openEvent)
event.cancel(failEvent)
print("Cancelled all event listeners")
loop = false
end
eventEngaged = event.listen("stargate_spin_chevron_engaged", function(evname, address, caller, num, lock, glyph)
os.sleep(0.5)
if lock then
print("Engaging...")
sg.engageGate()
else
dialNext(num)
end
end)
dialNext(0)
openEvent = event.listen("stargate_open", function()
print("Stargate opened successfully")
cancelEvents()
end)
failEvent = event.listen("stargate_failed", function()
print("Stargate failed to open")
cancelEvents()
end)
while loop do os.sleep(0.1) end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment