smart rednet receive?
Started by pofferman, Dec 21 2015 06:56 PM
10 replies to this topic
#1
Posted 21 December 2015 - 06:56 PM
Is there any smart rednet receive trick, for receiveing more than 1 rednet signal at once?
Like if i were to broadcast("Hello there.")
And then all the other 5 computers could send a reply at the same time "Well hello there newcommoner!".
And then my computer would be able to print out all the 5 different recesves.
Any help is appreciated. Thanks
Like if i were to broadcast("Hello there.")
And then all the other 5 computers could send a reply at the same time "Well hello there newcommoner!".
And then my computer would be able to print out all the 5 different recesves.
Any help is appreciated. Thanks
#2
Posted 21 December 2015 - 07:16 PM
rednet also triggers events (in fact rednet.receive is just waiting to receive one of these events)
so if you listen for rednet events manually and print the message yourself, you should be good.
due to the nature of CC you can't actually receive multiple events at the same time
This is (somewhat) related to the fact that no 2 CC computers run at the same time, only one computer runs, then it pauses to allow another to run.
so if you listen for rednet events manually and print the message yourself, you should be good.
while true do
local event = {os.pullEvent()}
--#if event == rednetEvent then
--#print the message
else
--#do something else
end
end
due to the nature of CC you can't actually receive multiple events at the same time
This is (somewhat) related to the fact that no 2 CC computers run at the same time, only one computer runs, then it pauses to allow another to run.
Edited by Lupus590, 21 December 2015 - 07:20 PM.
#3
Posted 21 December 2015 - 07:24 PM
Lupus590, on 21 December 2015 - 07:16 PM, said:
--#if event == rednetEvent then
if event[1] == "rednet_message" then
Edited by TheOddByte, 21 December 2015 - 09:17 PM.
#4
#5
Posted 21 December 2015 - 08:25 PM
So if i listen to the pullEvent instead, i will be able to receive all the messages without anyone of them lost into the deep dark void of nothing?
#6
Posted 21 December 2015 - 09:16 PM
os.pull event will give you one message
you will need to keep pulling events until there are no more rednet events
you will need to keep pulling events until there are no more rednet events
#7
Posted 21 December 2015 - 09:23 PM
Lupus590, on 21 December 2015 - 07:32 PM, said:
Woops, fixed that
pofferman, on 21 December 2015 - 08:25 PM, said:
So if i listen to the pullEvent instead, i will be able to receive all the messages without anyone of them lost into the deep dark void of nothing?
But that's also the reason you'd want to put it in a loop, because the function only returns one event.
Here's an example
#8
Posted 22 December 2015 - 04:11 PM
So the rednet_message will get stacked in some sort of buffer until its used, in a short time?
Correct me if im wrong.
Correct me if im wrong.
#9
Posted 22 December 2015 - 04:32 PM
pofferman, on 22 December 2015 - 04:11 PM, said:
So the rednet_message will get stacked in some sort of buffer until its used, in a short time?
Correct me if im wrong.
Correct me if im wrong.
All events stack in this way, in the event queue. AFAIK it is not timed, although there is a limit of 255 events in the queue. It's not really until it's used, more of until the program requests an event (yields).
#10
Posted 22 December 2015 - 05:00 PM
Oke thanks, will tests your feedback when i can
ty.
#11
Posted 22 December 2015 - 06:05 PM
It worked.
Thank you guys for the help
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











