Difference between revisions of "Rednet (API)"
From ComputerCraft Wiki
m (moved REDNET to Rednet (API)) |
|||
Line 1: | Line 1: | ||
The rednet API provides a simple computer networking model over RedPower bundled cables. | The rednet API provides a simple computer networking model over RedPower bundled cables. | ||
+ | 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. | ||
{| border="1" cellpadding="2" cellspacing="0" | {| border="1" cellpadding="2" cellspacing="0" | ||
!style="background:#EEE" width="200px"|Method name | !style="background:#EEE" width="200px"|Method name | ||
Line 11: | Line 12: | ||
|- | |- | ||
|rednet.announce() | |rednet.announce() | ||
− | | | + | |Broadcasts an empty rednet message. |
|- | |- | ||
|rednet.send( receiverID, message ) | |rednet.send( receiverID, message ) | ||
− | |Sends a message to the computer using the opened sides. | + | |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. |
|- | |- | ||
|rednet.broadcast( message ) | |rednet.broadcast( message ) | ||
− | |Sends the message to ALL computers. | + | |Sends the message to ALL connected and open computers. |
|- | |- | ||
|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 ) |
|} | |} | ||
You can also handle the "rednet_message" event to receive messages without calling receive(), the arguments are the same as the receive() return values. | You can also handle the "rednet_message" event to receive messages without calling receive(), the arguments are the same as the receive() return values. | ||
[[Category:APIs]] | [[Category:APIs]] |
Revision as of 04:45, 5 February 2012
The rednet API provides a simple computer networking model over RedPower bundled cables. 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 |
---|---|
rednet.open( side ) | Tells the computer that the side can be used for networking. |
rednet.close( side ) | Tells the computer that the side can no longer be used for networking. |
rednet.announce() | Broadcasts an empty rednet 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. |
rednet.broadcast( message ) | Sends the message to ALL connected and open computers. |
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 ) |
You can also handle the "rednet_message" event to receive messages without calling receive(), the arguments are the same as the receive() return values.