Difference between revisions of "Rednet.receive"
From ComputerCraft Wiki
m |
(Changing float to number) |
||
| Line 2: | Line 2: | ||
{{Function | {{Function | ||
|name=rednet.receive | |name=rednet.receive | ||
| − | |args= | + | |args={{type|number}} timeoutSeconds |
|returns=senderID, message, distance-to-sender (or <code>nil</code> if using redpower bundled cable instead of a modem) | |returns=senderID, message, distance-to-sender (or <code>nil</code> if using redpower bundled cable instead of a modem) | ||
|api=rednet | |api=rednet | ||
Revision as of 11:53, 18 July 2013
| Waits for timeoutSeconds or until another computer sends a message to this computer. (see rednet.broadcast( message ) and rednet.send( receiverID, message ). If a Timeout occurs the return id and message are set to nil. If timeout is nil, waits forever. To get the id from a computer see os.getComputerID(), or the id program. 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(number timeoutSeconds) |
| Returns | senderID, message, distance-to-sender (or nil if using redpower bundled cable instead of a modem) |
| Part of | ComputerCraft |
| API | rednet |
Examples
| Waits forever until someone sends a message to this computer and displays it. | |
| Code |
local senderId, message, distance = rednet.receive() |
| Output | The received message. |