rednet.send

From ComputerCraft Wiki
Revision as of 18:38, 4 June 2014 by Apemanzilla (Talk | contribs)

Jump to: navigation, search


Grid Redstone.png  Function rednet.send
Allows a computer / turtle with an attached modem to send a message intended for a system with a specific ID. At least one such modem must first be "opened" with eg rednet.open() before sending is possible. Assuming the target was in range and also had a correctly opened modem, that can then use rednet.receive() to collect the message. See also rednet.broadcast().

Note that any systems in range (ie, connected to your Wired Modem network cable runs or close enough to your Wireless Modems) are capable of receiving the message if their owners have some idea what ID you're targeting - they need only use modem.open() to manually open the corresponding channel(s) you're using on their systems, and they have full access to your communications. Use of rednet.open() only opens certain channels (selected automatically) - this is a "convenience" feature, not a "security" feature.

Messages are typically strings, however later versions of ComputerCraft (which?) may alternatively send tables instead. Those on older versions may find textutils.serialize() useful when wanting to transmit tables.

To get the ID of a given system, refer to os.computerID().
Syntax rednet.send(number receiverID, string message)
Returns boolean success code. True if a message has been sent (note - "sent", as opposed to "received" or even "was receivable"), false if not.
Part of ComputerCraft
API rednet

Examples

Grid paper.png  Example
Sends a message to the system with the ID of 22 (assuming a modem is attached and open).
Code
rednet.send(22,"ComputerCraft")