Manual:DIL Manual/SFB CMD
Jump to navigation
Jump to search
SFB_CMD
Constant (integer, vme.h: 0x0004).
wait(SFB_CMD, condition)
The command event. A program waiting with SFB_CMD (in wait() or interrupt()) wakes whenever a player or a monster near it types a command, before the command runs. That includes commands the server doesn't know, commands the character isn't allowed to use, moving in a direction, and commands that DIL runs with exec(). Because the command hasn't happened yet, the program can stop it with block.
What the event holds
| Variable | Value |
|---|---|
| activator | the character who typed the command |
| argument | the rest of the line, without the spaces at either end ("all from corpse") |
| cmdstr | the full name of the command ("get") |
| excmdstr | the word as typed, in lower case ("ge") |
| excmdstr_case | the word exactly as typed ("Ge") |
| command("get") | TRUE |
| medium, target | null |
Notes
- Commands are matched by name:
command("north")is also true when the player typed "n". There are noCMD_NORTHorCMD_GETconstants; only the automatic events have numbers (CMD_AUTO_*in vme.h). - A word the server doesn't know comes as
CMD_AUTO_UNKNOWN, andcommand("tester")is true when the typed word is the start of "tester". Unless a program blocks it, the server then answers "... is not a known command.", so a program that makes up its own command mustblock. - The event reaches the character's room, the things the character carries and wears, everything else in the room (other characters, but of them only what they wear, and what is inside open transparent units), and the room around the room if this one is transparent.
- A program doesn't get the commands of the unit it runs on, unless it is declared
aware(dilbegin aware name();). A program on a player that watches what the player types needsaware. - The event comes before the level and position checks, so a program also sees commands the character can't use.
- When characters follow someone, each follower's step sends its own
SFB_CMDfor the direction, with an empty argument. - The programs on a unit get the event one after another, in
fnpriorder. Ablockstops the command and every program after this one; give a blocking program a low priority, such asFN_PRI_BLOCK. activatorand the other values belong to this event only. Unit variables that aren't secured become null at every wake, so copy what you need right after the wait.
Example
dilbegin fnpri(FN_PRI_BLOCK) guardnorth();
code
{
heartbeat := PULSE_SEC * 5;
:start:
wait(SFB_CMD, command("north") and (activator.type == UNIT_ST_PC));
if (activator.level >= IMMORTAL_LEVEL)
goto start;
act("$1n steps in front of you and shakes $1s head.",
A_SOMEONE, self, null, activator, TO_VICT);
block;
goto start;
}
dilend
A guard who stops mortal players from going north.