Difference between revisions of "Rednet (API)"

From ComputerCraft Wiki
Jump to: navigation, search
(Undo revision 1728 by 91.121.152.54 (talk))
m (Fixed formatting)
Line 8: Line 8:
 
!style="background:#EEE" width="80px"|Return type
 
!style="background:#EEE" width="80px"|Return type
 
|-
 
|-
|[[rednet.open|rednet.open( side )]]
+
|[[rednet.open|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
 
|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
 
|nil
Line 20: Line 20:
 
|nil
 
|nil
 
|-
 
|-
|[[rednet.send|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
 
|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
 
|success
 
|-
 
|-
|[[rednet.receive]]( timeout )
+
|[[rednet.receive]](timeout)
 
|Waits until it received a rednet message or <var>timeout</var> has passed. Leave args empty to wait for a message forever.
 
|Waits until it received a rednet message or <var>timeout</var> has passed. Leave args empty to wait for a message forever.
 
|senderId, message, distance
 
|senderId, message, distance
Line 40: Line 40:
 
|-
 
|-
 
|rednet_message
 
|rednet_message
|Fired when a rednet message is received (can be used as alternative for rednet.receive()
+
|Fired when a rednet message is received (can be used as alternative for rednet.receive())
 
|senderId, message, distance
 
|senderId, message, distance
 
[[Category:APIs]]
 
[[Category:APIs]]

Revision as of 11:34, 24 June 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.

Methods

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) Waits until it received a rednet message or timeout has passed. Leave args empty to wait for a message forever. senderId, message, distance

Events

Method name Description Parameters
rednet_message Fired when a rednet message is received (can be used as alternative for rednet.receive()) senderId, message, distance