Difference between revisions of "Rednet.broadcast"
From ComputerCraft Wiki
(Corrected mapping from "Boolean" to "Boolean (type)") |
Bomb Bloke (Talk | contribs) (CC 1.6 update adds protocols) |
||
Line 2: | Line 2: | ||
{{Function | {{Function | ||
|name=rednet.broadcast | |name=rednet.broadcast | ||
− | |args=[ | + | |args={{type|string}} message, [<nowiki/>{{type|string}} protocol] |
− | |returns=[[boolean_(type)|boolean]] success code. True if a message has been sent, false if not. | + | |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= | + | |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> |
+ | |||
+ | ComputerCraft 1.6 introduces optional "[[Rednet (API)#Protocols|protocol]]" - 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. | ||
|examples= | |examples= | ||
{{Example | {{Example | ||
− | |desc=Sends a | + | |desc=Sends a message to all nearby systems (assuming a modem is attached and open). |
|code=rednet.broadcast("ComputerCraft") | |code=rednet.broadcast("ComputerCraft") | ||
+ | }} | ||
+ | {{Example | ||
+ | |desc=Sends a message to all nearby systems, specifying a protocol of "TestMessages". | ||
+ | |code=rednet.broadcast("ComputerCraft","TestMessages") | ||
}} | }} | ||
}} | }} | ||
+ | |||
+ | {{RednetAPIFunctions}} | ||
[[Category:API_Functions]] | [[Category:API_Functions]] |
Revision as of 06:33, 6 June 2014
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. ComputerCraft 1.6 introduces optional "protocol" - 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(string message, [string protocol]) |
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
Example | |
Sends a message to all nearby systems (assuming a modem is attached and open). | |
Code |
rednet.broadcast("ComputerCraft") |
Example | |
Sends a message to all nearby systems, specifying a protocol of "TestMessages". | |
Code |
rednet.broadcast("ComputerCraft","TestMessages") |
Rednet API Functions |
---|
rednet.open - rednet.close - rednet.send - rednet.broadcast - rednet.receive - rednet.isOpen - rednet.host - rednet.unhost - rednet.lookup |