Core Help Root: Commands: @add-command


PROGRAMMER COMMAND

Syntax: @add-c?ommand|@ac "<Command Template>" [to|for] <objref>

Used to add a command. The method called if the command matches must be specified. The command template must be an Enhanced Command Template. Arguments send to the method are always ordered the same, the first argument is always the command string, followed by subsequent arguments relative to how the command template would match using template matching (see Matching Conventions).

For instance, the following enhanced command template:

"@get <any> from <this>"

Would evaluate to the following standard template:

"@get * from *"

From this point, you can simply evaluate the template matching to see how its results would be ordered:

;match_template("@get something from nothing", "@get * from *")
=> ["@get", "something", "from", "nothing"]

Based off these results the arg definition for your method could be:

arg cmdstr, cmd, arg1, prep, arg2;

When a command is added it will not immediately begin working. Command caches must be updated first. There are three different situations that will arise when adding a command:

Adding a local command to yourself

This situation is the simplest to update. If you have added a command to yourself simply type @rehash, and your local caches will be updated.

Adding a remote command to an object

When adding a remote command to something you can rehash the remote caches by simply dropping the item and picking it back up.

Adding a local command to another object

If you are adding a local command to an object other than yourself, you will have to rehash the entire system's caches. This is done with the command @rehash-all, which is an administrative command.




the Cold Dark