hi i'm looking to create and run a program that will automatically close the iris when a connection comes into the gate (figured that out)
then open it with a message (got that too). the part hat is confuseing me however is how do I filter it so that the program is only looking at what was typed to be sent. e.g. if the code was 12345 how do i get it to read that instead of reading sgMessageReceived "souceaddress" 12345?
Code so far:
component = require("component")
event = require("event")
sg = component.proxy("...") --- deliberately put the three dots here as it changes
event.pull("sgDialIn")
sg.closeIris()
event.pull("sgMessageReceived")
sg.openIris()
thats what I have so far the problem is it opens the gate when it receives any message from the other-side of a gate. Anybody have any ideas?
Edit: Nevermind I got it figured out.
Useing my gates and 12345 as a test password this is what worked for me:
c = require("component")
e = require("event")
s = c.getPrimary("stargate")
e.pull("sgDialIn")
print("Incoming Wormhole")
print("Closing Iris")
s.closeIris()
e.pull("sgStargateStateChange")
print("Awaiting Signal")
local _, remoteAddress, payload = e.pull("sgMessageReceived")
if payload == "12345" then
print("Code Accpeted, Opening Iris")
s.openIris()
else if payload ~= "12345" then
print("Code Not Accepted, Disconnecting Gate")
s.disconnect()
e.pull("sgStargateStateChange")
print("Gate Disconnected, Opening Iris")
s.openIris()
print("Good-Bye")
end
end
edit 2
And more importantly this is wireless:
Using 420 as the port and 12345 as a test password:
computer must have a wireless network card
computer connected to gate needs this program:
c = require("component")
e = require("event")
t = require("term")
local m = c.modem
s = c.getPrimary("stargate")
t.clear()
while true do
print(e.pull("sgDialIn"))
print("Incoming Wormhole")
print("Closing Iris")
s.closeIris()
m.open(420) --- Choose whatever port you want
print("Channel Open")
e.pull("sgStargateStateChange")
print("Awaiting Signal")
local _, _, from, port, _, message = e.pull("modem_message")
if message == "12345" then --- choose whatever password you want
print("Code Accpeted, Opening Iris")
s.openIris()
os.sleep(2)
m.broadcast(420, "Iris Open") --- port must be the same as the one you chose earlier
print("Welcome Home")
os.sleep(10)
print("Closing Gate")
s.disconnect()
else if message ~= "12345" then ---password must be the same as the one you chose earlier
m.broadcast(420, "Code Rejected") --- port must be the same as the one you chose earlier
print("Code: " ..(message).." Not Accepted, Disconnecting Gate")
s.disconnect()
e.pull("sgStargateStateChange")
os.sleep(1)
print("Gate Disconnected, Opening Iris")
s.openIris()
print("Good-Bye")
end
end
end
and on the tablet :
tablet must haves: wireless network card and keyboard
local component = require("component")
local event = require("event")
local m = component.modem -- get primary modem component
m.open(420) --- port must be the same as the computer
print(m.isOpen(420)) -- true --- see above though this line is not really needed
-- Send some message.
m.broadcast(420, "12345") --- port and password must be the same as the computer
-- Wait for a message from another network card.
local _, _, from, port, _, message = event.pull("modem_message")
print(message)
Hope this works for you as well as it has for me.
edit 3: tweaked the code so there is less to change
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
hi i'm looking to create and run a program that will automatically close the iris when a connection comes into the gate (figured that out)
then open it with a message (got that too). the part hat is confuseing me however is how do I filter it so that the program is only looking at what was typed to be sent. e.g. if the code was 12345 how do i get it to read that instead of reading sgMessageReceived "souceaddress" 12345?
Code so far:
component = require("component")
event = require("event")
sg = component.proxy("...") --- deliberately put the three dots here as it changes
event.pull("sgDialIn")
sg.closeIris()
event.pull("sgMessageReceived")
sg.openIris()
thats what I have so far the problem is it opens the gate when it receives any message from the other-side of a gate. Anybody have any ideas?
Edit: Nevermind I got it figured out.
Useing my gates and 12345 as a test password this is what worked for me:
and on the tablet :
tablet must haves: wireless network card and keyboard
Link to post
Share on other sites