Create Slash Commands
Hi!, im new in Addon's development, and I'm having problems with the next Slash commands that I want to create, my idea is simple I just want to shortcuts, some personalize phrases , this is the code:
And btw, i don't know exactly what means the "msg" or "(txt)" does with "function " , and how does it affect the script SLASH_PHRASE = "/ph" SLASH_SPHRASE = "/sph" SlashCmdList ["PHRASE"] = function (msg) SendChatMessage ("Go to RBG!", GUILD") SlashCmdList["SPHRASE"] = function (msg) SendChatMessage("Do you want come with us to RBG?", "SAY") end Ok, the First /ph, works for the guild, but "SAY" is not working, and I have no clue. Q1: if I write "function ()" what it does? Q2: Could I use {} to just write 1 code line "SlashCmdList? -- sry for my English -- |
Lua Code:
|
(Thx for answering )
Now both stoped working :S "/ph" and "/sph", but I realized something (while waiting for an answer) I need to write first "/ph" so "/sph" could work if I use "/sph" before "/ph" , it doesn't work :S, any idea? |
Edit
I could make it work , adding the 1 , at the end of each Slash_
SLASH_PHRASE1 So It works! now :) now question 1, what is the difference between SlashCmdList = function(msg) and local function = <name>(msg) ? and what exactly does (msg) or (txt) in that line? question 2, is there function or array that I could use to get in one place all "local function " and "SendChatMessage", like a table or array"? |
Code:
SLASH_PHRASE1 = "/ph"; local anything is local to that module/code chunk and can't be "seen" outside of it. I'm not sure what you mean by SendChatMessage but if you mrean calls to the SendChatMessage function in code then no. |
Oh thx!,
now I would like to make an index, like Blizzard did with "/help" command but I having issues how to make print_array() into variable. the code is kind of tmp = {"alpha", "beta", "gamma"} function print_array(tbl) for i = 1, #tbl do print(i, tbl[i]) end end print_array(tmp) and that displays 1, alpha 2, beta 3, gamma I would like to show my /commands After I write /hcm -- Help command could display the next kind of table. 1, /ph , "you say , hello guild mates!" 2, /sph " an other phrase " but until now I have no clue how to make it just the so simple ones, with foo= 14, print (foo) :S |
I'm not sure if that was an actual question but if so, something like:
Lua Code:
|
Quote:
|
The part between the lines, if you type /ph (or /sph) without anything after it, it will print the list of options.
/ph Quote:
/ph 1 would be like doing Quote:
would be like doing Quote:
{ "chattype", "message" } as per SendChatMessage If you're only sending one chattype then you don't need that part. |
All times are GMT -6. The time now is 09:55 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI