Manual:DIL Manual/sendtoall()
Jump to navigation
Jump to search
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.