Difference between revisions of "Manual:DIL Manual/sendtoalldil()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = sendtoalldil() = | |
| − | + | '''Procedure.''' Sends a message to every running copy of a DIL template. | |
| − | |||
| − | |||
| − | |||
| − | + | sendtoalldil(m : string, s : string) | |
| − | + | Sends the message <code>m</code> to every program in the game made from the template | |
| + | <code>s</code> (<code>"name@zone"</code>), on whatever unit it runs. Each such program that waits | ||
| + | for <code>SFB_MSG</code> wakes up with <code>m</code> in <code>argument</code>, the sending unit | ||
| + | as <code>activator</code> and <code>medium</code>, and its own unit as <code>target</code>. | ||
| + | channel@function uses it to carry the chat channels to every player. | ||
| − | + | == Parameters == | |
| − | + | {| class="wikitable" | |
| − | + | ! Name !! Type !! Meaning | |
| − | + | |- | |
| + | | m || string || The message. | ||
| + | |- | ||
| + | | s || string || The template's name with its zone, <code>"name@zone"</code>. | ||
| + | |} | ||
| − | + | == Notes == | |
| − | < | + | * Without the <code>@zone</code>, 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 <code>aware</code>. | |
| − | + | * 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 <code>s</code> as a function. | |
| − | + | * The messages are delivered at once, before <code>sendtoalldil()</code> returns: the receivers run first. | |
| − | + | * A program waiting for something else gets nothing (unless an <code>interrupt(SFB_MSG, ...)</code> catches it). | |
| − | + | == Example == | |
| + | <pre> | ||
| + | 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 | ||
| + | </pre> | ||
| + | Raises the alarm with every gate guard (template <code>gate_guard</code> in a zone named castle), wherever the guards are. | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/sendtoall()|sendtoall()]] | |
| − | + | * [[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
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.