WOW Addon Teams

I am learning about wow addons and I would like to create a command that shows "Hello World" in chat when I typed "/ cht". I checked http://wowwiki.wikia.com/wiki/Creating_a_slash_command but my code doesn't work.

My code:

SLASH_CHAT = "/cht"
SlashCmdList["CHAT"] = function(msg)
        print("Hello World!")
end

      

Do you have an idea why it doesn't work?

Thanks in advance.

+3


source to share


2 answers


You need to change your global from SLASH_CHAT

to SLASH_CHAT1

, yes it really is that simple.



+8


source


I updated http://wowwiki.wikia.com/wiki/Creating_a_slash_command with examples installed and I added a simple starter example at the top with an abbreviated explanation of the mechanism and rules.

Some of the examples were obscure, but more importantly, the actual rules for naming were pretty buried, namely where the OP was having problems.

The new top example reads:

SLASH_TEST1 = "/test1"
SLASH_TEST2 = "/addontest1"
SlashCmdList["TEST"] = function(msg)
   print("Hello World!")
end 

      



It was not your fault. :)


Before editing:

Same text as above, mostly except that I forgot and the code I used to test it was complex and I misinterpreted it. I put the wrong information above with the above (and edited the entire wiki article the same way). Both are fixed now. The comment below complains about the original answer I made here.

+1


source







All Articles