A basic library for registering slash commands in the WAR interface.
If you're downloading this because an addon you want to use requires it, just extract it into the interface\addons directory, and that's all you need to do.
With LibSlash installed, you'll also be able to use /addon or /uimod to open the Addons window in-game.
If you're writing an addon and want to utilize LibSlash, place it in the proper addons directory along with your other addons. Then, add it as a dependency in your addon's .mod file, like so:
<Dependencies> <Dependency name="LibSlash" /> </Dependencies>
This will ensure that LibSlash is loaded before your addon, so that its functions will be available for use.
To register a slash command handler, call LibSlash.RegisterSlashCmd() with the slash command you want to register (a string, NOT INCLUDING THE /) and a function to serve as the handler:
LibSlash.RegisterSlashCmd("myslash", function(input) MyAddonHandleSlash(input) end)
The single argument passed to the handler is a string containing the rest of the chat line entered after the initial slash command, so the above code would call MyAddonHandleSlash with an argument of "testing" if I typed "/myslash testing" at the command line.
Alternatively, LibSlash.RegisterWSlashCmd() can be used to register a handler to receive a wstring version of the chat line, instead of having it automatically translated to a string.
To unregister a slash command, use LibSlash.UnregisterSlashCmd("myslash") - the only argument it takes is a string specifying the slash command to unregister. You can also use LibSlash.IsSlashCmdRegistered("myslash") to see if a slash command is already registered, possibly by another addon.
Both the register and unregister functions will return true on success, or false on failure for any reason such as attempting to register a slash command which is already registered, or other silly things.
- Date created
- Aug 20, 2008
- Last update
- May 19, 2010
- Development stage
- MIT License
- Curse link
- Reverse relationships
- Recent files