Difference between revisions of "Manual:DIL Manual/argument"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = argument = | |
| − | + | '''Variable''' (string, read-only). | |
| − | |||
| − | |||
| − | + | argument : string | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | The text that came with the event that woke the program: | |
| + | * SFB_CMD: what the player typed after the command word, with the spaces around it removed. For <code>'Hello there</code> (say) and <code>,smiles</code> (emote) it's the text after the mark. | ||
| + | * SFB_MSG: the message. | ||
| + | * SFB_PRE and SFB_DONE: what the sender passed. For damage, three numbers (attack group, attack number, hit location); for a spell, the spell number first; after a <code>give</code> of coins, the money type. | ||
| + | * SFB_TICK, SFB_DEAD, SFB_COM: <code>""</code>. | ||
| + | |||
| + | == Notes == | ||
| + | * In a player command written in DIL (<code>func =</code> in commands.def) the typed text is the template's string parameter; <code>argument</code> is <code>""</code> there. | ||
| + | * It belongs to the current event: after the next wait() or pause it is another event's. Copy it into a string variable (strings keep their value across waits). | ||
| + | * getword() and findunit() on <code>argument</code> take the word they use off it, for the rest of this activation. Copy it first if you need the whole text afterwards. | ||
| + | * <code>argument == "yes"</code> ignores case; <code>"word" in argument</code> is a substring test that also ignores case. | ||
| + | * It can't be assigned. | ||
| + | |||
| + | == Example == | ||
| + | <pre> | ||
| + | dilbegin parrot(); | ||
| + | var | ||
| + | said : string; | ||
| + | code | ||
| + | { | ||
| + | heartbeat := PULSE_SEC * 2; | ||
| + | |||
| + | :start: | ||
| + | wait(SFB_CMD, command("say") and (activator.type == UNIT_ST_PC)); | ||
| + | said := argument; | ||
| + | pause; | ||
| + | if (said != "") | ||
| + | exec("say " + said + "! Squawk!", self); | ||
| + | goto start; | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | A parrot that repeats what players say, a moment later. The text is copied into <code>said</code> before the pause. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/cmdstr|cmdstr]] | ||
| + | * [[Manual:DIL Manual/excmdstr|excmdstr]] | ||
| + | * [[Manual:DIL Manual/getword()|getword()]] | ||
| + | * [[Manual:DIL Manual/command()|command()]] | ||
| + | * [[Manual:DIL Manual/SFB CMD|SFB CMD]] | ||
| + | * [[Manual:DIL Manual/SFB MSG|SFB MSG]] | ||
Latest revision as of 23:19, 14 November 2026
Contents
argument
Variable (string, read-only).
argument : string
The text that came with the event that woke the program:
- SFB_CMD: what the player typed after the command word, with the spaces around it removed. For
'Hello there(say) and,smiles(emote) it's the text after the mark. - SFB_MSG: the message.
- SFB_PRE and SFB_DONE: what the sender passed. For damage, three numbers (attack group, attack number, hit location); for a spell, the spell number first; after a
giveof coins, the money type. - SFB_TICK, SFB_DEAD, SFB_COM:
"".
Notes
- In a player command written in DIL (
func =in commands.def) the typed text is the template's string parameter;argumentis""there. - It belongs to the current event: after the next wait() or pause it is another event's. Copy it into a string variable (strings keep their value across waits).
- getword() and findunit() on
argumenttake the word they use off it, for the rest of this activation. Copy it first if you need the whole text afterwards. argument == "yes"ignores case;"word" in argumentis a substring test that also ignores case.- It can't be assigned.
Example
dilbegin parrot();
var
said : string;
code
{
heartbeat := PULSE_SEC * 2;
:start:
wait(SFB_CMD, command("say") and (activator.type == UNIT_ST_PC));
said := argument;
pause;
if (said != "")
exec("say " + said + "! Squawk!", self);
goto start;
}
dilend
A parrot that repeats what players say, a moment later. The text is copied into said before the pause.