time to read doc/script_command.txt.
*bindatcmd "command","<NPC object name>::<event label>"{,<group level>,<group level char>,<log>};
This command will bind a NPC event label to an atcommand. Upon execution
of the atcommand, the user will invoke the NPC event label. Each atcommand
is only allowed one binding. If you rebind, it will override the original
binding. If group level is provided, only users of that group level or
above will be able to access the command, if not provided, everyone will
be able to access the command.
"group level char" is the minimum group level required for the label to be
used on others like a char command would, e.g. "#command "target" params",
when not provided, "group level char" defaults to 99.
"log" whether to log the usages of this command with the atcommand log
(1 = log, 0 = no log), default is to not log.
The following variables are set upon execution:
.@atcmd_command$ = The name of the @command used.
.@atcmd_parameters$[] = Array containing the given parameters,
starting from an index of 0.
.@atcmd_numparameters = The number of parameters defined.
Parameters are split on spaces. Multiple spaces aren't grouped together, and
will create multiple (empty) arguments.
Any leading spaces before the first parameter will be omitted.
- script atcmd_example -1,{
OnInit:
bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
end;
OnAtcommand:
specialeffect2 338;
end;
}
Parameter splitting example:
@mycommand
.@atcmd_numparameters -> 0
.@atcmd_parameters$ -> { }
@mycommand<space><space>
.@atcmd_numparameters -> 0
.@atcmd_parameters$ -> { }
@mycommand<space>foo
.@atcmd_numparameters -> 1
.@atcmd_parameters$ -> { "foo" }
@mycommand<space><space>foo
.@atcmd_numparameters -> 1
.@atcmd_parameters$ -> { "foo" }
@mycommand<space>foo<space>bar
.@atcmd_numparameters -> 2
.@atcmd_parameters$ -> { "foo", "bar" }
@mycommand<space>foo<space><space>bar
.@atcmd_numparameters -> 3
.@atcmd_parameters$ -> { "foo", "", "bar" }
@mycommand<space>foo<space>
.@atcmd_numparameters -> 2
.@atcmd_parameters$ -> { "foo", "" }
@mycommand<space>foo<space><space>
.@atcmd_numparameters -> 3
.@atcmd_parameters$ -> { "foo", "", "" }
- script atcmd_example -1,{
OnInit:
bindatcmd "test",strnpcinfo(3)+"::OnAtcommand";
end;
OnAtcommand:
// This command expects a character name (that may contain spaces) as
// the only parameter.
.@name$ = "";
for (.@i = 0; .@i < .@atcmd_numparameters; ++.@i) {
.@name$ += (.@i > 0 ? " " : "") + .@atcmd_parameters$[.@i];
}
dispbottom("The specified name is: '" + .@name$ + "'");
end;
}