Difference between revisions of "Rednet.receive"
From ComputerCraft Wiki
Line 6: | Line 6: | ||
|api=rednet | |api=rednet | ||
|addon=ComputerCraft | |addon=ComputerCraft | ||
− | |desc=Waits for <var>timeoutSeconds</var> or until another computer sends 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()]], or the [[id]] command. If a Timeout occurs the return id and message are set to nil.<br/>You must be calling this function at the moment a message is sent, or you will miss it. If you need to watch for messages while doing something else at the same time, | + | |desc=Waits for <var>timeoutSeconds</var> or until another computer sends 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()]], or the [[id]] command. If a Timeout occurs the return id and message are set to nil.<br/>You must be calling this function at the moment a message is sent, or you will miss it. If you need to watch for messages while doing something else at the same time, see [[Parallel.waitForAny]] |
|examples= | |examples= | ||
{{Example | {{Example |
Revision as of 01:50, 2 October 2012
Function rednet.receive | |
Waits for timeoutSeconds or until another computer sends a message to this computer. (see rednet.broadcast( message ) and rednet.send( receiverID, message ). To get the id from a computer see os.computerID(), or the id command. If a Timeout occurs the return id and message are set to nil. You must be calling this function at the moment a message is sent, or you will miss it. If you need to watch for messages while doing something else at the same time, see Parallel.waitForAny | |
Syntax | rednet.receive(float timeoutSeconds) |
Returns | senderId, message, distance-to-sender (or nil if using redpower bundled cable instead of a modem) |
Part of | ComputerCraft |
API | rednet |
Examples
Example | |
Waits forever until someone sends a message to this computer and displays it. | |
Code |
senderId, message, distance = rednet.receive() |
Output | The received message. |