Manual:DIL Manual/cmdstr
Jump to navigation
Jump to search
Contents
cmdstr
Variable (string, read-only).
cmdstr : string
The full name of the command in the event that woke the program, as commands.def names it, even when the player typed an abbreviation: n gives "north", 'hi gives "say". For a word that is no command, it's that word in lower case.
It is set in SFB_CMD events and in the SFB_DONE and SFB_PRE events of a command (after a give, "give"), and the first time a player command written in DIL runs. For ticks, messages, damage and other events that aren't a named command it is null, and comparing it with a string gives false.
Notes
cmdstr + " " + argumentis not what the player typed: the abbreviation is expanded and the spaces are trimmed. excmdstr is the word as typed.- To test for a command, use command(). cmdstr is for when the name is needed as text, for instance to repeat the command: basemove.zon's follow does
c := cmdstr;and laterexec(c, self);. - It belongs to the current event; copy it into a variable before a wait or pause.
- It can't be assigned.
Example
dilbegin fnpri(FN_PRI_BLOCK) gate_guard();
code
{
:start:
wait(SFB_CMD, (command("north") or command("up")) and
(activator.type == UNIT_ST_PC));
if (self.position < POSITION_STANDING)
goto start;
block;
act("$1n stops you from going $2t.", A_SOMEONE, self, cmdstr, activator, TO_VICT);
act("$1n stops $3n from going $2t.", A_SOMEONE, self, cmdstr, activator, TO_NOTVICT);
goto start;
}
dilend
A guard that blocks players going north or up, and names the direction in full whatever they typed.