Manual:DIL Manual/SFB MSG
Jump to navigation
Jump to search
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.