Gaming
 

Talk:Creating a slash command

From WoWWiki

I can't do it!!!!

Ok, I'm starting work on a simple test addon as a way to get to grips with lua and xml and the other aspects of coding. I've been using WoW UI Designer for it, largely because it's all I have, and I'm not confident enough to hard-code with notepad just yet! Anyway, I want to create a /easyinfo slash command to show the basic UI element of the project (EasyinfoForm), so I did this:

function Easyinfo_OnLoad()
SLASH_EASYINFO1 = "/easyinfo";
SLASH_EASYINFO2 = "/ezi";
SlashCmdList["MYSCRIPT"] = EasyinfoForm:Show();
end

All that happens when I type /easyinfo or /ezi in on wow is that it comes up with a "type /help for a few commands" thing in the console... my command isn't recognised.

I have loaded the addon, it has a current UI number and I didn't typo the command (I tried several times each time I altered the code, embarrasingly it was throwing up an error to begin with because I had put in "Easyinfo_Onload();" instead of "Easyinfo_Onload()")

Thanks in advance. -- Yoda  talk / cont 13:21, 23 March 2007 (EDT)

Hey Yoda. Two things. Change:
SlashCmdList["MYSCRIPT"] = EasyinfoForm:Show();
to
SlashCmdList["EASYINFO"] = EasyinfoForm:Show;
I was tripped up with mine own setup like this. If you say " = function()" instead of " = function", the LUA engine sets the SlashCmdList for your :addon to the function's RESULT rather than name.
Hope that helps. Rihlsul 20:04, 12 April 2007 (EDT)
I know this is over a year old, but it should be this SlashCmdList["EASYINFO"] = EasyinfoForm.Show; -- note, the dot, not the colon Posted by: EGingell (talk | contribs) on 04:19, 12 January 2009 (UTC)

Making secondary slash commands

Say I have the function /addon. I want /addon to do a number of things when different values are proceeding it (/addon information for example). Could somebody please explain how do this for me? TuskertheGreat (talk) 04:39, 16 May 2009 (UTC)

There's examples of this very thing here, Extracting info from a slash command. Posted by: EGingell (talk | contribs) on 16:16, 16 May 2009 (UTC)
Thanks for that, it helps. I was really just looking at /slash command stuff, which a friend explained to me, but I will definitely refer to that guide if I need to go more in depth. TuskertheGreat (talk) 23:45, 16 May 2009 (UTC)