→Simple Example
(→The Details: made it more clear) |
|||
| Line 7: | Line 7: | ||
end | end | ||
In your OnLoad function of your script, or in the .lua anyplace after the function is defined, put in the following: | In your '''OnLoad function''' of your script, ''or'' in the .lua '''anyplace after the function is defined''', put in the following: | ||
SLASH_MYSCRIPT1 = "/myscript"; | SLASH_MYSCRIPT1 = "/myscript"; | ||
SLASH_MYSCRIPT2 = "/mys"; -- A shortcut or alias | SLASH_MYSCRIPT2 = "/mys"; -- A shortcut or alias | ||
SlashCmdList["MYSCRIPT"] = MyScript_Command; | SlashCmdList["MYSCRIPT"] = MyScript_Command; | ||
Note: The slash command(s) must be defined in an OnLoad Function or after the function has been defined. | |||
EX. | |||
OnLoad Function: | |||
function addonname_OnLoad() | |||
SlashCmdList["ADDONNAME"] = FunctionToCall; | |||
SLASH_ADDONNAME1 = "/slash1"; | |||
SLASH_ADDONNAME2 = "/slash2"; | |||
end | |||
After Function Has Been Defined: | |||
function my_function() | |||
-- Some stuff here | |||
end | |||
SlashCmdList["ADDONNAME"] = FunctionToCall; | |||
SLASH_ADDONNAME1 = "/slash1"; | |||
SLASH_ADDONNAME2 = "/slash2"; | |||
== The Details == | == The Details == | ||