→The Details: made it more clear
m (→Simple Example) |
(→The Details: made it more clear) |
||
| Line 14: | Line 14: | ||
== The Details == | == The Details == | ||
<pre>SLASH_<CommandId><num> | |||
SlashCmdList["<CommandId>"] = <CodeToExecute></pre> | |||
Slash command parsing is done by the chat frame, and it works as follows. | Slash command parsing is done by the chat frame, and it works as follows. | ||
* The key of each entry is the <CommandId>. It should be the unique name of your Addon. | |||
* The parser then examines <b>SLASH_<i><CommandId></i>1</b>, <b>SLASH_<i><CommandId></i>2</b>, ... and so on, until it either finds a match, or gets a nil value (undefined) on the next <b>SLASH_<i><CommandId></i><i><Number></i></b>. | |||
* If there was a hit, then the function value of <b>SlashCmdList["<i><CommandId></i>"]</b> is invoked, with the rest of the command line as its single parameter | |||
* Special 'built in' slash commands for chat are handled first. | * Special 'built in' slash commands for chat are handled first. | ||
* The chat handler then iterates over the contents of the global table <b>SlashCmdList</b> | * The chat handler then iterates over the contents of the global table <b>SlashCmdList</b> | ||
* Otherwise, the next command is searched until a match is found or the list is exhausted. | * Otherwise, the next command is searched until a match is found or the list is exhausted. | ||