Difference between revisions of "Manual:DIL Manual/excmdstr case"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
 
(checked against the compiler and the interpreter; example compiles)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 +
= excmdstr_case =
 +
'''Variable''' (string, read-only).
  
 +
excmdstr_case : string
  
−
<span id="excmdstr_case"></span>
+
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.
−
'excmdstr_case'
 
−
    This variable is a string which contains the "first string" which was entered
 
−
    by a player. The result of adding:
 
  
−
      excmdstr_case + " " + argument
+
== 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.
  
−
    is the entire string as entered by the player.
+
== Example ==
−
    The 'excmdstr' is not changed in anyway from how a player types it.
+
<pre>
−
    If a player types 'S' then the 'excmdstr_case' will have 'S' in it.
+
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

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) and block.
  • == on strings ignores case, so excmdstr_case == "Mellon" is also true for mellon. For an exact match use strcmp(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.

See also