Difference between revisions of "Manual:DIL Manual/excmdstr case"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = excmdstr_case = | |
| − | + | '''Variable''' (string, read-only). | |
| − | |||
| − | |||
| − | + | excmdstr_case : string | |
| − | + | The first word of the line the player typed, exactly as typed: <code>Mellon</code> stays <code>"Mellon"</code>. Otherwise the same as excmdstr: <code>'</code> gives <code>"say"</code>, <code>,</code> gives <code>"emote"</code>, and it is null outside a typed command. | |
| − | |||
| − | |||
| + | == Notes == | ||
| + | * Use it where case matters, such as a password typed at a prompt: commands.zon's password command reads it after <code>wait(SFB_CMD, self == activator)</code> and <code>block</code>. | ||
| + | * <code>==</code> on strings ignores case, so <code>excmdstr_case == "Mellon"</code> is also true for <code>mellon</code>. For an exact match use <code>strcmp(excmdstr_case, "Mellon") == 0</code>. | ||
| + | * Only the first word: the rest of the line is in <code>argument</code>, which keeps its case. | ||
| + | * Like excmdstr it belongs to the command: an exec() of the same command while handling it leaves it null. Copy it first. | ||
| − | + | == Example == | |
| − | < | + | <pre> |
| − | + | dilbegin secret_word(); | |
| − | + | var | |
| − | + | word : string; | |
| + | code | ||
| + | { | ||
| + | sendtext("Speak the word, exactly as it is written: ", self); | ||
| + | wait(SFB_CMD, activator == self); | ||
| + | block; | ||
| + | word := excmdstr_case; | ||
| + | if (strcmp(word, "Mellon") == 0) | ||
| + | sendtext("The doors swing open.<br/>", self); | ||
| + | else | ||
| + | sendtext("Nothing happens.<br/>", self); | ||
| + | quit; | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | Asks the player for a word and accepts only <code>Mellon</code> with that capital letter. The <code>block</code> keeps the word from running as a command. | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/excmdstr|excmdstr]] | |
| − | + | * [[Manual:DIL Manual/cmdstr|cmdstr]] | |
| − | + | * [[Manual:DIL Manual/strcmp()|strcmp()]] | |
| − | + | * [[Manual:DIL Manual/block|block]] | |
| − | |||
| − | |||
| − | |||
Latest revision as of 23:19, 14 November 2026
Contents
excmdstr_case
Variable (string, read-only).
excmdstr_case : string
The first word of the line the player typed, exactly as typed: Mellon stays "Mellon". Otherwise the same as excmdstr: ' gives "say", , gives "emote", and it is null outside a typed command.
Notes
- Use it where case matters, such as a password typed at a prompt: commands.zon's password command reads it after
wait(SFB_CMD, self == activator)andblock. ==on strings ignores case, soexcmdstr_case == "Mellon"is also true formellon. For an exact match usestrcmp(excmdstr_case, "Mellon") == 0.- Only the first word: the rest of the line is in
argument, which keeps its case. - Like excmdstr it belongs to the command: an exec() of the same command while handling it leaves it null. Copy it first.
Example
dilbegin secret_word();
var
word : string;
code
{
sendtext("Speak the word, exactly as it is written: ", self);
wait(SFB_CMD, activator == self);
block;
word := excmdstr_case;
if (strcmp(word, "Mellon") == 0)
sendtext("The doors swing open.<br/>", self);
else
sendtext("Nothing happens.<br/>", self);
quit;
}
dilend
Asks the player for a word and accepts only Mellon with that capital letter. The block keeps the word from running as a command.