Skip to content
everloot

Lore archive · Warcraft Wiki, 2023 dump

GetSlashFunc

Last wiki revision 2009-12-22

Returns the function called when using. slashFunction = (cmd)

  • (cmd)
  • cmd : the slash command to search for
  • the actual function called when executing the cmd.

local func = GetSlashFunc("/quit") SLASH_MYQUIT1 = "/quit" SLASH_MYQUIT2 = "/exit" SlashCmdList["MYQUIT"] = function(msg) if msg == "now" then ForceQuit elseif func then func end end

  • Quit now instead of in 30 seconds when is used.

-- returns a slash command function on success or an informative error function on failure. local function GetSlashFunc(cmd) if not cmd then return function(cmd) print("You must supply a command.") end end if cmd:sub(1, 1) ~= "/" then cmd = "/" .. cmd end for id, val in pairs(_G) do if id:sub(1, 5) == "SLASH" and val == cmd then local slashID = id:match("SLASH_(%a*)%d*") return SlashCmdList[slashID] end end -- Didn't find one? return function(cmd) print(cmd, "doesn't exist.") end end

  • This will not work to hook secure commands such as, , , etc. The functions that are called with those commands are not globally accessible to addon scripts and, if they were, you would just end up breaking stuff.
  • If an addon creates its slash command after yours, yours will no longer work (as per usual).

Source

https://warcraft.wiki.gg/wiki/GetSlashFunc · retrieved 2023-11-13 · CC BY-SA 4.0

Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.

This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.