9 posts
Location
Global Domination HQ, UKRI
Posted 04 December 2016 - 02:38 AM
I have a script that I have, and I want it inside an infinite loop to broadcast a message, and print any received messages.
Is this possible?
Edited on 04 December 2016 - 01:39 AM
3057 posts
Location
United States of America
Posted 04 December 2016 - 02:45 AM
It is absolutely possible.
local id = os.startTimer(0)
while true do
local event = {os.pullEvent()}
if event[ 1 ] == "timer" and event[ 2 ] == id then
id = os.startTimer(1) --#sending one message a second should be sufficient.
rednet.broadcast( "a message" )
elseif event[ 1 ] == "rednet_message" then
print( event[ 3 ] )
end
end
Edited on 04 December 2016 - 01:46 AM
9 posts
Location
Global Domination HQ, UKRI
Posted 04 December 2016 - 02:48 AM
It is absolutely possible.
local id = os.startTimer(0)
while true do
local event = {os.pullEvent()}
if event[ 1 ] == "timer" and event[ 2 ] == id then
id = os.startTimer(1) --#sending one message a second should be sufficient.
rednet.broadcast( "a message" )
elseif event[ 1 ] == "rednet_message" then
print( event[ 3 ] )
end
end
Thanks!