-- command (string) - chat command to be registered WITHOUT leading "/" |
-- func (function|membername) - function to call, or self[membername](self, ...) call |
-- persist (boolean) - false: the command will be soft disabled/enabled when aceconsole is used as a mixin (default: true) |
-- silent (boolean) - don't whine if command already exists, silently fail |
-- |
-- Register a simple chat command |
function AceConsole:RegisterChatCommand( command, func, persist ) |
if type(command)~="string" then error([[Usage: AceConsole:RegisterChatCommand( "command", func[, persist ]): 'command' - expected a string]], 2) end |
function AceConsole:RegisterChatCommand( command, func, persist, silent ) |
if type(command)~="string" then error([[Usage: AceConsole:RegisterChatCommand( "command", func[, persist[, silent] ]): 'command' - expected a string]], 2) end |
|
if persist==nil then persist=true end -- I'd rather have my addon's "/addon enable" around if the author screws up. Having some extra slash regged when it shouldnt be isn't as destructive. True is a better default. /Mikk |
|
local name = "ACECONSOLE_"..command:upper() |
|
if SlashCmdList[name] then |
if not silent then |
geterrorhandler()(tostring(self)..": Chat Command '"..command.."' already exists, will not overwrite.") |
end |
return |
end |
if type( func ) == "string" then |
SlashCmdList[name] = function(input) |
self[func](self, input) |