Difference between revisions of "Rednet (API)"
From ComputerCraft Wiki
(Added Links to empty pages for future "Wikias" ?) |
(added return column) |
||
Line 4: | Line 4: | ||
!style="background:#EEE" width="200px"|Method name | !style="background:#EEE" width="200px"|Method name | ||
!style="background:#EEE" width="*"|Description | !style="background:#EEE" width="*"|Description | ||
+ | !style="background:#EEE" width="80px"|Return type | ||
|- | |- | ||
|[[rednet.open( side )]] | |[[rednet.open( side )]] | ||
|Tells the computer that the side can be used for networking. | |Tells the computer that the side can be used for networking. | ||
+ | |nil | ||
|- | |- | ||
|[[rednet.close( side )]] | |[[rednet.close( side )]] | ||
|Tells the computer that the side can no longer be used for networking. | |Tells the computer that the side can no longer be used for networking. | ||
+ | |nil | ||
|- | |- | ||
|[[rednet.announce()]] | |[[rednet.announce()]] | ||
|Broadcasts an empty rednet message. | |Broadcasts an empty rednet message. | ||
+ | |nil | ||
|- | |- | ||
|[[rednet.send( receiverID, message )]] | |[[rednet.send( receiverID, message )]] | ||
|Sends a message to the computer using the opened sides. The receiver ID is the ID (number, not string) of the computer you're sending the message to. | |Sends a message to the computer using the opened sides. The receiver ID is the ID (number, not string) of the computer you're sending the message to. | ||
+ | |success | ||
|- | |- | ||
|[[rednet.broadcast( message )]] | |[[rednet.broadcast( message )]] | ||
|Sends the message to ALL connected and open computers. | |Sends the message to ALL connected and open computers. | ||
+ | |success | ||
|- | |- | ||
|[[rednet.receive( timeout )]] | |[[rednet.receive( timeout )]] | ||
|Sets an amount of time to wait for a rednet message input. If you wanted to have the computer wait for an input for 5 seconds, then the code would be: rednet.receive( 5 ) If you wanted it to continuously receive then don't put anything between the (). | |Sets an amount of time to wait for a rednet message input. If you wanted to have the computer wait for an input for 5 seconds, then the code would be: rednet.receive( 5 ) If you wanted it to continuously receive then don't put anything between the (). | ||
+ | |senderId, message, distance | ||
|} | |} | ||
− | You can also handle the "rednet_message" event to receive messages without calling receive() | + | You can also handle the "rednet_message" event to receive messages without calling receive(). Its arguments are (senderId, message, distance). |
[[Category:APIs]] | [[Category:APIs]] |
Revision as of 17:30, 25 April 2012
The rednet API provides a simple computer networking model over RedPower bundled cables or the Wireless Modems of Computercraft 1.3. With the table below, 'side' refers to a string that represents a side of the computer ("front", "back", "left", "right", "bottom", "top"). All message sent with rednet are and must be strings.
Method name | Description | Return type |
---|---|---|
rednet.open( side ) | Tells the computer that the side can be used for networking. | nil |
rednet.close( side ) | Tells the computer that the side can no longer be used for networking. | nil |
rednet.announce() | Broadcasts an empty rednet message. | nil |
rednet.send( receiverID, message ) | Sends a message to the computer using the opened sides. The receiver ID is the ID (number, not string) of the computer you're sending the message to. | success |
rednet.broadcast( message ) | Sends the message to ALL connected and open computers. | success |
rednet.receive( timeout ) | Sets an amount of time to wait for a rednet message input. If you wanted to have the computer wait for an input for 5 seconds, then the code would be: rednet.receive( 5 ) If you wanted it to continuously receive then don't put anything between the (). | senderId, message, distance |
You can also handle the "rednet_message" event to receive messages without calling receive(). Its arguments are (senderId, message, distance).