Manual:DIL Manual/sendtoalldil()
Jump to navigation
Jump to search
sendtoalldil()
Procedure. Sends a message to every running copy of a DIL template.
sendtoalldil(m : string, s : string)
Sends the message m to every program in the game made from the template
s ("name@zone"), on whatever unit it runs. Each such program that waits
for SFB_MSG wakes up with m in argument, the sending unit
as activator and medium, and its own unit as target.
channel@function uses it to carry the chat channels to every player.
Parameters
| Name | Type | Meaning |
|---|---|---|
| m | string | The message. |
| s | string | The template's name with its zone, "name@zone".
|
Notes
- Without the
@zone, or for a template that doesn't exist, nothing is sent. - The sending program itself never gets the message. Another copy on the same unit gets it only when it is
aware. - Only programs made from that template (copied onto a unit) are reached, and only while they are in the template itself: one that waits inside a function it called gets nothing, and so does a program of another template that calls
sas a function. - The messages are delivered at once, before
sendtoalldil()returns: the receivers run first. - A program waiting for something else gets nothing (unless an
interrupt(SFB_MSG, ...)catches it).
Example
dilbegin raise_alarm();
code
{
sendtoalldil("alarm " + self.outside.title, "gate_guard@castle");
quit;
}
dilend
dilbegin gate_guard();
var
s : string;
w : string;
code
{
:start:
wait(SFB_MSG, "alarm" in argument);
s := argument;
w := getword(s); // takes "alarm" off s
exec("shout To arms! Trouble at " + s + "!", self);
goto start;
}
dilend
Raises the alarm with every gate guard (template gate_guard in a zone named castle), wherever the guards are.