Difference between revisions of "Rednet.receive"
From ComputerCraft Wiki
(document distance-to-sender return) |
|||
Line 1: | Line 1: | ||
{{lowercase}} | {{lowercase}} | ||
{{Function | {{Function | ||
− | |name=rednet.receive | + | |name=rednet.receive |
− | |args= | + | |args=[[float (type)|float]] timeout |
− | |returns= | + | |returns=[[table (type)|table]] with senderId, message, distance-to-sender (or <code>nil</code> if using redpower bundled cable instead of a modem) |
|api=rednet | |api=rednet | ||
|addon=ComputerCraft | |addon=ComputerCraft | ||
− | |desc=Waits till timeout or another computer send a message to this computer. (see [[rednet.broadcast( message )]] and [[rednet.send( receiverID, message )]]. To get the id from a computer see [[os.computerID()]]. In case a Timeout occurs the return id and message are set to nil | + | |desc=Waits till <var>timeout</var> or another computer send a message to this computer. (see [[rednet.broadcast( message )]] and [[rednet.send( receiverID, message )]].<br />To get the id from a computer see [[os.computerID()]]. In case a Timeout occurs the return id and message are set to nil |
|examples= | |examples= | ||
{{Example | {{Example | ||
|desc=waits unlimited till someone sends a message to this computer and displays it | |desc=waits unlimited till someone sends a message to this computer and displays it | ||
|code=senderId, message, distance = rednet.receive()<br>term.write(message) | |code=senderId, message, distance = rednet.receive()<br>term.write(message) | ||
+ | |output=The received message. | ||
}} | }} | ||
}} | }} |
Revision as of 08:01, 30 May 2012
Function rednet.receive | |
Waits till timeout or another computer send a message to this computer. (see rednet.broadcast( message ) and rednet.send( receiverID, message ). To get the id from a computer see os.computerID(). In case a Timeout occurs the return id and message are set to nil | |
Syntax | rednet.receive(float timeout) |
Returns | table with senderId, message, distance-to-sender (or nil if using redpower bundled cable instead of a modem) |
Part of | ComputerCraft |
API | rednet |
Examples
Example | |
waits unlimited till someone sends a message to this computer and displays it | |
Code |
senderId, message, distance = rednet.receive() |
Output | The received message. |