rednet.receive
Function rednet.receive | |
Waits for timeout seconds, or until a rednet_message event is found in the event queue (with a matching protocol, if specified). The system must have a modem that's been readied for rednet usage in order for this to function; messages may then be sent to it from remote systems via rednet.send() / rednet.broadcast(). Due to the nature of how events are pulled, using this function will generally cause the system to discard and ignore any other events that occur until the message is received or the time out ends (though Ctrl+T can generally be used to terminate it, if need be). Likewise, if the system is not specifically listening when a given message is sent, chances are high that another "event-eating" function (eg a turtle movement call or most anything else that pauses code execution, such as "sleep") will discard it, making it impossible to "receive". This issue can be bypassed using co-routines - notably, the parallel API offers easy work-arounds. If a time out value is specified and reached, then nil is returned. Note that protocols are only supported by ComputerCraft 1.6 or later - versions prior returned the distance between the sender and receiver instead (information that can still be gained by inspecting modem_message events directly, but which may not be "accurate" depending on whether any Rednet repeaters are active on your network). | |
Syntax | rednet.receive([ [string protocolFilter, ] number timeout]) |
Returns | number senderID, string message, string protocol |
Part of | ComputerCraft |
API | rednet |
Examples
Rednet API Functions |
---|
rednet.open - rednet.close - rednet.send - rednet.broadcast - rednet.receive - rednet.isOpen - rednet.host - rednet.unhost - rednet.lookup |