Difference between revisions of "Rednet.broadcast"

From ComputerCraft Wiki
Jump to: navigation, search
(Fixed return parameters from boolean to nil)
(Works with types other than strings.)
 
Line 2: Line 2:
 
{{Function
 
{{Function
 
|name=rednet.broadcast
 
|name=rednet.broadcast
|args={{type|string}} message, [<nowiki/>{{type|string}} protocol]
+
|args={{type|any}} message, [<nowiki/>{{type|string}} protocol]
 
|returns=None
 
|returns=None
 
|api=rednet
 
|api=rednet
 
|addon=ComputerCraft
 
|addon=ComputerCraft
|desc=[[rednet.send|rednet.send()s]] a message on channel 65535. Any [[modem]] in range [[rednet.open|readied for rednet use]] will be able to [[rednet.receive|receive]] it.<br><br>
+
|desc=[[rednet.send|rednet.send()s]] a message on channel 65535. Any [[modem]] in range [[rednet.open|readied for rednet use]] will be able to [[rednet.receive|receive]] it.
 +
 
 +
Most data types can be sent, but functions / coroutines are converted to nil. In the past tables were also converted to nil, and required the use of [[textutils.serialize]]() to transmit - they can now be sent directly ''(exact build which changed things is unknown, but CC 1.53 works and 1.5 does not)''.
  
 
ComputerCraft 1.6 introduces optional "[[Rednet (API)#Protocols|protocol]]s" - simple string names indicating what the message is about. Receiving systems may filter messages according to their protocols, thereby automatically ignoring incoming messages which don't specify an identical string. It's also possible to [[rednet.lookup|lookup]] which systems in the area are interested in certain protocols, hence making it easier to determine where given messages should be sent in the first place.
 
ComputerCraft 1.6 introduces optional "[[Rednet (API)#Protocols|protocol]]s" - simple string names indicating what the message is about. Receiving systems may filter messages according to their protocols, thereby automatically ignoring incoming messages which don't specify an identical string. It's also possible to [[rednet.lookup|lookup]] which systems in the area are interested in certain protocols, hence making it easier to determine where given messages should be sent in the first place.

Latest revision as of 13:50, 14 June 2015


Grid Redstone.png  Function rednet.broadcast
rednet.send()s a message on channel 65535. Any modem in range readied for rednet use will be able to receive it.

Most data types can be sent, but functions / coroutines are converted to nil. In the past tables were also converted to nil, and required the use of textutils.serialize() to transmit - they can now be sent directly (exact build which changed things is unknown, but CC 1.53 works and 1.5 does not).

ComputerCraft 1.6 introduces optional "protocols" - simple string names indicating what the message is about. Receiving systems may filter messages according to their protocols, thereby automatically ignoring incoming messages which don't specify an identical string. It's also possible to lookup which systems in the area are interested in certain protocols, hence making it easier to determine where given messages should be sent in the first place.
Syntax rednet.broadcast(any message, [string protocol])
Returns None
Part of ComputerCraft
API rednet

Examples

Grid paper.png  Example
Sends a message to all nearby systems (assuming a modem is attached and open).
Code
rednet.broadcast("ComputerCraft")



Grid paper.png  Example
Sends a message to all nearby systems, specifying a protocol of "TestMessages".
Code
rednet.broadcast("ComputerCraft","TestMessages")


Grid disk.png Rednet API Functions
rednet.open - rednet.close - rednet.send - rednet.broadcast - rednet.receive - rednet.isOpen - rednet.host - rednet.unhost - rednet.lookup