Difference between revisions of "Manual:DIL Manual/sendtoall()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
| + | = sendtoall() = | ||
| + | '''Procedure.''' Sends a message to every copy of a unit in the game. | ||
| + | sendtoall(m : string, s : string) | ||
| − | < | + | Sends the message <code>m</code> to every unit in the game made from the definition |
| − | + | <code>s</code> (<code>"name@zone"</code>, e.g. every <code>"bag@arena"</code>). Each DIL | |
| − | + | program on those units that waits for <code>SFB_MSG</code> wakes up with <code>m</code> in | |
| − | + | <code>argument</code>, and the sending unit as <code>activator</code> and <code>medium</code>. | |
| − | |||
| − | + | To reach the programs made from one template, wherever they run, use | |
| + | [[Manual:DIL Manual/sendtoalldil()|sendtoalldil()]]; to reach one unit, | ||
| + | [[Manual:DIL Manual/sendto()|sendto()]]. | ||
| − | + | == Parameters == | |
| + | {| class="wikitable" | ||
| + | ! Name !! Type !! Meaning | ||
| + | |- | ||
| + | | m || string || The message. | ||
| + | |- | ||
| + | | s || string || The units' symbolic name with its zone, <code>"name@zone"</code>. | ||
| + | |} | ||
| − | + | == Notes == | |
| − | + | * Without the <code>@zone</code>, or for a name that doesn't exist, nothing is sent. | |
| − | + | * The messages are delivered at once, before <code>sendtoall()</code> returns: the receivers run first. | |
| + | * A program waiting for something else gets nothing (unless an <code>interrupt(SFB_MSG, ...)</code> catches it). | ||
| + | * If the sending unit is itself such a unit, its own programs get the message only when they are <code>aware</code>. | ||
| + | * A program that blocks or takes <code>priority</code> keeps the message from the programs after it on the same unit. | ||
| − | + | == Example == | |
| + | <pre> | ||
| + | dilbegin arena_over(); | ||
| + | code | ||
| + | { | ||
| + | sendtoall("emptyout", "bag@arena"); | ||
| + | quit; | ||
| + | } | ||
| + | dilend | ||
| + | |||
| + | dilbegin bag_wait(); | ||
| + | code | ||
| + | { | ||
| + | :start: | ||
| + | wait(SFB_MSG, argument == "emptyout"); | ||
| + | if (self.outside.type == UNIT_ST_PC) | ||
| + | act("Your $2N disappears.", A_SOMEONE, self.outside, self, null, TO_CHAR); | ||
| + | destroy(self); | ||
| + | quit; | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | When the arena closes, every arena bag in the game vanishes, as in arena.zon. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/sendtoalldil()|sendtoalldil()]] | ||
| + | * [[Manual:DIL Manual/sendto()|sendto()]] | ||
| + | * [[Manual:DIL Manual/send()|send()]] | ||
| + | * [[Manual:DIL Manual/wait()|wait()]] | ||
| + | * [[Manual:DIL Manual/interrupt()|interrupt()]] | ||
Latest revision as of 23:22, 14 November 2026
sendtoall()
Procedure. Sends a message to every copy of a unit in the game.
sendtoall(m : string, s : string)
Sends the message m to every unit in the game made from the definition
s ("name@zone", e.g. every "bag@arena"). Each DIL
program on those units that waits for SFB_MSG wakes up with m in
argument, and the sending unit as activator and medium.
To reach the programs made from one template, wherever they run, use sendtoalldil(); to reach one unit, sendto().
Parameters
| Name | Type | Meaning |
|---|---|---|
| m | string | The message. |
| s | string | The units' symbolic name with its zone, "name@zone".
|
Notes
- Without the
@zone, or for a name that doesn't exist, nothing is sent. - The messages are delivered at once, before
sendtoall()returns: the receivers run first. - A program waiting for something else gets nothing (unless an
interrupt(SFB_MSG, ...)catches it). - If the sending unit is itself such a unit, its own programs get the message only when they are
aware. - A program that blocks or takes
prioritykeeps the message from the programs after it on the same unit.
Example
dilbegin arena_over();
code
{
sendtoall("emptyout", "bag@arena");
quit;
}
dilend
dilbegin bag_wait();
code
{
:start:
wait(SFB_MSG, argument == "emptyout");
if (self.outside.type == UNIT_ST_PC)
act("Your $2N disappears.", A_SOMEONE, self.outside, self, null, TO_CHAR);
destroy(self);
quit;
}
dilend
When the arena closes, every arena bag in the game vanishes, as in arena.zon.