Difference between revisions of "Manual:DIL Manual/SFB MSG"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = SFB_MSG = | |
| + | '''Constant''' (integer, vme.h: 0x0040). | ||
| − | SFB_MSG | + | wait(SFB_MSG, condition) |
| − | + | The message event: how DIL programs talk to each other. A program sends a text with <code>send()</code>, <code>sendto()</code>, <code>sendtoall()</code> or <code>sendtoalldil()</code>; a program waiting with <code>SFB_MSG</code> wakes with the text in <code>argument</code>. | |
| − | |||
| − | + | == What the event holds == | |
| − | + | {| class="wikitable" | |
| + | ! Variable !! Value | ||
| + | |- | ||
| + | | activator || the unit whose program sent the message | ||
| + | |- | ||
| + | | argument || the text that was sent | ||
| + | |- | ||
| + | | command(CMD_AUTO_MSG) || TRUE | ||
| + | |- | ||
| + | | medium || null; with <code>sendtoall()</code> and <code>sendtoalldil()</code> the sender too | ||
| + | |- | ||
| + | | target || null; with <code>sendtoalldil()</code> the unit receiving it | ||
| + | |} | ||
| − | + | == Who gets it == | |
| + | * <code>send(msg)</code>: the sender's surroundings, as a command (see [[Manual:DIL Manual/SFB CMD|SFB_CMD]]). The other programs on the sending unit get it only if they are declared <code>aware</code>. | ||
| + | * <code>sendto(msg, u)</code>: every program on <code>u</code>, the sender's own programs too when <code>u</code> is the sender. | ||
| + | * <code>sendtoall(msg, "sym@zone")</code>: the programs on every copy of that unit in the game. | ||
| + | * <code>sendtoalldil(msg, "tmpl@zone")</code>: every running copy of that template, except the one sending. | ||
| + | == Notes == | ||
| + | * A program that is running can't be woken. While the sender is still busy after its send, a message sent back to it is lost; it can only be caught by programs that are waiting. | ||
| + | * Messages are not queued: a program that is busy, or waiting for another kind of event, misses them. Use <code>interrupt(SFB_MSG, ...)</code> to catch a message while waiting for something else. | ||
| + | * Compare texts with <code>==</code> (which ignores case) or test words with <code>in</code>. | ||
| − | + | == Example == | |
| − | + | <pre> | |
| − | + | dilbegin herald(); | |
| + | code | ||
| + | { | ||
| + | heartbeat := PULSE_SEC * 5; | ||
| − | + | :start: | |
| − | + | wait(SFB_MSG, argument == "gate open"); | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| + | exec("shout The gate stands open!", self); | ||
| + | goto start; | ||
| + | } | ||
| + | dilend | ||
| − | + | dilbegin gatekeeper(); | |
| + | code | ||
| + | { | ||
| + | :start: | ||
| + | wait(SFB_CMD, command("say") and ("open sesame" in argument)); | ||
| − | + | send("gate open"); | |
| + | goto start; | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | When a player says "open sesame" next to the gatekeeper, it tells the room, and a herald in the same room shouts the news. | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/send()|send()]] | |
| − | + | * [[Manual:DIL Manual/sendto()|sendto()]] | |
| − | + | * [[Manual:DIL Manual/sendtoall()|sendtoall()]] | |
| − | + | * [[Manual:DIL Manual/sendtoalldil()|sendtoalldil()]] | |
| − | + | * [[Manual:DIL Manual/interrupt()|interrupt()]] | |
| − | + | * [[Manual:DIL Manual/aware|aware]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 23:24, 14 November 2026
SFB_MSG
Constant (integer, vme.h: 0x0040).
wait(SFB_MSG, condition)
The message event: how DIL programs talk to each other. A program sends a text with send(), sendto(), sendtoall() or sendtoalldil(); a program waiting with SFB_MSG wakes with the text in argument.
What the event holds
| Variable | Value |
|---|---|
| activator | the unit whose program sent the message |
| argument | the text that was sent |
| command(CMD_AUTO_MSG) | TRUE |
| medium | null; with sendtoall() and sendtoalldil() the sender too
|
| target | null; with sendtoalldil() the unit receiving it
|
Who gets it
send(msg): the sender's surroundings, as a command (see SFB_CMD). The other programs on the sending unit get it only if they are declaredaware.sendto(msg, u): every program onu, the sender's own programs too whenuis the sender.sendtoall(msg, "sym@zone"): the programs on every copy of that unit in the game.sendtoalldil(msg, "tmpl@zone"): every running copy of that template, except the one sending.
Notes
- A program that is running can't be woken. While the sender is still busy after its send, a message sent back to it is lost; it can only be caught by programs that are waiting.
- Messages are not queued: a program that is busy, or waiting for another kind of event, misses them. Use
interrupt(SFB_MSG, ...)to catch a message while waiting for something else. - Compare texts with
==(which ignores case) or test words within.
Example
dilbegin herald();
code
{
heartbeat := PULSE_SEC * 5;
:start:
wait(SFB_MSG, argument == "gate open");
exec("shout The gate stands open!", self);
goto start;
}
dilend
dilbegin gatekeeper();
code
{
:start:
wait(SFB_CMD, command("say") and ("open sesame" in argument));
send("gate open");
goto start;
}
dilend
When a player says "open sesame" next to the gatekeeper, it tells the room, and a herald in the same room shouts the news.