Difference between revisions of "Rednet.send"

From ComputerCraft Wiki
Jump to: navigation, search
(fixing links)
("WaitUntilPortOpen" is not currently a valid parameter; suspect it was pre-1.5 behaviour?)
Line 2: Line 2:
 
{{Function
 
{{Function
 
|name=rednet.send
 
|name=rednet.send
|args={{type|number}} receiverID, {{type|string}} message, {{type|boolean}} WaitUntilPortOpen
+
|args={{type|number}} receiverID, {{type|string}} message
|returns=[[boolean_(type)|boolean]] success code. True if a message has been sent, false if not. "true" does not guarantee, that the destination was reachable!
+
|returns=[[boolean_(type)|boolean]] success code. True if a message has been sent (note - "sent", as opposed to "received" or even "was receivable"), false if not.
 
|api=rednet
 
|api=rednet
 
|addon=ComputerCraft
 
|addon=ComputerCraft
|desc=Sends a message to a specific Computer or Turtle. (see [[rednet.broadcast|rednet.broadcast( message )]] and [[rednet.receive|rednet.receive( timeout )]].<br />To get the id from a computer see [[os.computerID|os.computerID()]]. Setting WaitUntilPortOpen to True can help when the server is not receiving a response from the responding client.
+
|desc=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|rednet.open()]] before sending is possible. Assuming the target was in range and also had a correctly opened modem, it can then use [[rednet.receive|rednet.receive()]] to collect the message. See also [[rednet.broadcast|rednet.broadcast()]].<br><br>
 +
 
 +
Note that any systems in range are capable of receiving the message if their owners have some idea what ID you're targeting - they need only use [[Modem.open|modem.open()]]
 +
 
 +
To get the ID of a given system, refer to [[os.computerID|os.computerID()]].
 
|examples=
 
|examples=
 
{{Example
 
{{Example
|desc=Sends a Message to the Computer with the ID 22 (assuming a modem is attached and open), and will wait until the port is available to use.
+
|desc=Sends a message to the system with the ID of 22 (assuming a modem is attached and open).
|code=rednet.send(22,"ComputerCraft", true)
+
|code=rednet.send(22,"ComputerCraft")
 
}}
 
}}
 
}}
 
}}
  
 
[[Category:API_Functions]]
 
[[Category:API_Functions]]

Revision as of 01:00, 24 February 2014


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, it can then use rednet.receive() to collect the message. See also rednet.broadcast().

Note that any systems in range are capable of receiving the message if their owners have some idea what ID you're targeting - they need only use modem.open()

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")