Difference between revisions of "Rednet (API)"
m (Put the note in the wrong place :P) |
Smiley43210 (Talk | contribs) m (Added types) |
||
Line 16: | Line 16: | ||
<tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr> | <tr><td style="width: 350px; background: #E0E0E0; padding: .4em; font-weight:bold;">Method Name</td><td style="background: #E0E0E0; padding: .4em; font-weight:bold;">Description</td></tr> | ||
− | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.open]](side)</td> | + | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.open]]({{type|string}} side)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Tells the computer that the side can be used for networking.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Tells the computer that the side can be used for networking.</td></tr> | ||
− | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.close]](side)</td> | + | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.close]]({{type|string}} side)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Tells the computer that the side can no longer be used for networking.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Tells the computer that the side can no longer be used for networking.</td></tr> | ||
Line 25: | Line 25: | ||
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Broadcasts an empty rednet message.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Broadcasts an empty rednet message.</td></tr> | ||
− | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.send]](receiverID, message)</td> | + | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.send]]({{type|int}} receiverID, message)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">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. ID as nil will do the same as a broadcast. The message must be a string to send across rednet, if you are wanting to send a table see [[textutils.serialize]]</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">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. ID as nil will do the same as a broadcast. The message must be a string to send across rednet, if you are wanting to send a table see [[textutils.serialize]]</td></tr> | ||
Line 31: | Line 31: | ||
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sends the message to ALL connected and open computers.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Sends the message to ALL connected and open computers.</td></tr> | ||
− | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.receive]](timeout)</td> | + | <tr style="background-color: #E8E8E8;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.receive]]({{type|int}} timeout)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Waits until it received a rednet message or <var>timeout</var> has passed. Leave args empty to wait for a message forever.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Waits until it received a rednet message or <var>timeout</var> has passed. Leave args empty to wait for a message forever.</td></tr> | ||
− | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.isOpen]](side)</td> | + | <tr style="background-color: #FFFFFF;"><td style="border-top: solid #C9C9C9 1px; padding: .4em;">[[rednet.isOpen]]({{type|string}} side)</td> |
<td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns true if the wireless modem is open.</td></tr> | <td style="border-top: solid #C9C9C9 1px; padding: .4em;">Returns true if the wireless modem is open.</td></tr> | ||
</table> | </table> |
Revision as of 14:51, 2 May 2013
Please Note As of ComputerCraft 1.5, the Rednet API is just a wrapper for modems and channels, and no longer supports
transmitting data through Bundled Cables. However interacting with Bundled Cables is still available via the Redstone API |
The Rednet API allows computers to communicate between themselves without using redstone wires. In order to send and receive data, a modem is required. The data is received immediately after sending it, but only by computers within a certain range. That range depends on the altitude of the sending computer increasing with higher altitudes to a max of 384. NOTE: The distance variable that is sent/received through the Rednet API is based off of the computer location, not the modem location.
Method Name | Description |
rednet.open(string side) | Tells the computer that the side can be used for networking. |
rednet.close(string side) | Tells the computer that the side can no longer be used for networking. |
rednet.announce() | Broadcasts an empty rednet message. |
rednet.send(int 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. ID as nil will do the same as a broadcast. The message must be a string to send across rednet, if you are wanting to send a table see textutils.serialize |
rednet.broadcast(message) | Sends the message to ALL connected and open computers. |
rednet.receive(int timeout) | Waits until it received a rednet message or timeout has passed. Leave args empty to wait for a message forever. |
rednet.isOpen(string side) | Returns true if the wireless modem is open. |
Events
Event name | Description | Parameters |
---|---|---|
rednet_message | Fired when a rednet message is received (can be used as alternative for rednet.receive()) | senderId, message, distance |
History
Before the creation of the in-game wireless networking API, the term "Rednet" referred to a system created by one of the ComputerCraft users based on bundled cables from a popular Minecraft mod - RedPower. It also allowed communication between computers, but the data was transferred slowly - every bit was converted to redstone signal, that lasted about 0,1 seconds. On the release of ComputerCraft 1.3, the system became useless, as the wireless networking was officially implemented to the mod.