This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ExtraRandom's profile picture

how to detect message received (Rednet) (Need help)

Started by ExtraRandom, 02 September 2012 - 11:39 AM
ExtraRandom #1
Posted 02 September 2012 - 01:39 PM
hia, how do you make it so a pc detects the message sent and depending on that message it does something. i think its "if receive = message" but that seems stupid.
sjele #2
Posted 02 September 2012 - 02:01 PM

event, p1, p2 = os.pullEvent()
if event == "rednet_message" then
  print("sender : "..p1.." message: "..p2..")
--Stuff to do when we got a renet msg
end
 

That would lookfor /find a msg and store it as p2 and print it.
dcleondc #3
Posted 02 September 2012 - 05:14 PM
you can also do it this way

id, msg, dis rednet.receive(timeout)  -- like io.read where it will wait
print("From: "..id)
print("Message: "..msg)
this is how i do all my rednet things