Last active
June 11, 2021 01:21
-
-
Save MrJake222/c4f8eab50dd91e8b133a8d51616d7eb7 to your computer and use it in GitHub Desktop.
Simple dialing program for AUNIS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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