Jump to content




Checking if rednet receive has timed out?


  • You cannot reply to this topic
3 replies to this topic

#1 Jasonfran

  • Members
  • 148 posts
  • LocationEngland

Posted 05 December 2012 - 08:37 AM

How do you check if the rednet receive timed out. I have it set up properly to get messages but I can't find how to find out when it times out so I can do something.

#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 05 December 2012 - 08:41 AM

If you use rednet.receive() with no arguments, it will continue forever until it receives a rednet message of any kind. Using rednet.receive(timeout) will allow you to use a specific timeout period. Say... (5) seconds.

#3 Jasonfran

  • Members
  • 148 posts
  • LocationEngland

Posted 05 December 2012 - 08:49 AM

View PostCranium, on 05 December 2012 - 08:41 AM, said:

If you use rednet.receive() with no arguments, it will continue forever until it receives a rednet message of any kind. Using rednet.receive(timeout) will allow you to use a specific timeout period. Say... (5) seconds.
I know that, I was just wondering how you check when it has timed out. But I think I got it as the message is returned as nothing

#4 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 05 December 2012 - 09:13 AM

The only thing you can do is check like this:
local id, msg, dist = rednet.receive(5)
if not msg then
    print("message not received")
else
--do other stuff
end






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users