Manual:DIL Manual/excmdstr
Jump to navigation
Jump to search
Contents
excmdstr
Variable (string, read-only).
excmdstr : string
The first word of the line the player typed, in lower case, not expanded: N gives "n", where cmdstr gives "north". A line starting with ' gives "say", one starting with , gives "emote". A word that is no command is there too.
It is set while a typed command is being handled: in SFB_CMD events, in the SFB_DONE and SFB_PRE events of that command, and the first time a player command written in DIL runs. Otherwise (ticks, messages, after the command) it is null.
Notes
- Use it to insist on the full word: commands.zon's quit refuses with
if (excmdstr != "quit"). - It reads typed input that isn't a command: competition.zon's menu takes a number with
atoi(excmdstr)afterwait(SFB_CMD, ...). excmdstr + " " + argumentis the line as typed, apart from case and spacing. excmdstr_case keeps the case.- It belongs to the command, not to the event: if the program exec()s the same command while handling it, excmdstr is null afterwards. Copy it into a variable first.
- It can't be assigned.
Example
dilbegin do_retire(arg : string);
code
{
if (excmdstr != "retire")
{
sendtext("You typed '" + excmdstr + "'. Type 'retire', no less, to retire.<br/>", self);
quit;
}
sendtext("You retire from adventuring.<br/>", self);
quit;
}
dilend
A player command (func = do_retire@zone in commands.def) that only works when typed in full, as quit in commands.zon.