Rednet Confirmation When Sent
#1
Posted 20 December 2012 - 03:55 AM
Thanks
#2
Posted 20 December 2012 - 04:03 AM
local id, msg while true do rednet.send(someID, someSignal) id, msg = rednet.receive(5) if id and msg then break end end -- do stuff
This script basically sends a signal to whatever ID, then waits 5 seconds for a response. If it gets a response, it gets out of the loop. Otherwise, it just goes back to the beginning and try again.
EDIT: Just realized you could do this:
local id, msg while not id and not msg do rednet.send(someID, someSignal) id, msg = rednet.receive(5) end -- do stuff
But do whatever works for you.
#3
Posted 20 December 2012 - 12:35 PM
- Send out message
- Wait for an "ACK" to be sent back from that same computer (this means all computers need to be setup to send an "ACK" back after receiving any message except an "ACK", and making it wait for an "ACK" from the computer it sent to, means it wont bug out on broadcasts or other terminals sending an "ACK")
- If no "ACK" in say 1 second (should theoretically be enough time, if not bump it up
) send message again until ACK received.
Hope this helps
#4
Posted 21 December 2012 - 06:24 AM
TheOriginalBIT, on 20 December 2012 - 12:35 PM, said:
local id, msg while true do rednet.send(someID, someSignal) id, msg = rednet.receive(5) if id == someID then break end end
#5
Posted 21 December 2012 - 07:28 AM
And for the love of Cloudy's pet peeves, use:
local id, msg repeat rednet.send(someID, someSignal) id, msg = rednet.receive(5) until id == someIDIt is also a pet peeve of mine as well.
Oh wait, I just realized that it was a one line modification of your previous code.
Edited by ChunLing, 21 December 2012 - 07:30 AM.
#6
Posted 21 December 2012 - 11:54 AM
Kingdaro, on 21 December 2012 - 06:24 AM, said:
TheOriginalBIT, on 20 December 2012 - 12:35 PM, said:
local id, msg while true do rednet.send(someID, someSignal) id, msg = rednet.receive(5) if id == someID then break end end
And again what if he doesn't want to program all the computer IDs into the program.
#7
Posted 21 December 2012 - 01:27 PM
ChunLing, on 21 December 2012 - 07:28 AM, said:
And for the love of Cloudy's pet peeves, use:
local id, msg repeat rednet.send(someID, someSignal) id, msg = rednet.receive(5) until id == someIDIt is also a pet peeve of mine as well.
TheOriginalBIT, on 21 December 2012 - 11:54 AM, said:
local id, msg
while true do
rednet.send(tonumber(({...})[1]), someSignal)
id, msg = rednet.receive(5)
if id == someID then break end
end
#8
Posted 21 December 2012 - 01:40 PM
Kingdaro, on 21 December 2012 - 01:27 PM, said:
Nah I meant more like one of the systems I used to run. I was adding a new computer every day or so and I didn't then want to go back around to all the computers just to add that new computers ID to a list so they could talk to it, so i made the code dynamic so that all i do is tell the new one what it is and then it broadcasts to the rest what it is, and then they all add it into their table and the save file so they can communicate later.
#9
Posted 21 December 2012 - 01:47 PM
#10
Posted 21 December 2012 - 01:53 PM
#11
Posted 21 December 2012 - 02:04 PM
But that's doesn't change the functionality of the part that uses the ID's, it just changes how they get into the program.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











