How to execute a slash-command?
Hello,
Sorry if it is a stupid question but I would like to execute a slash-command in a script and I don't know how this can be done. I tried: local myCommand = "/raresist"; RunScript(myCommand); SendChatMessage(myCommand,"SAY"); SendChatMessage(myCommand,"EMOTE"); DoEmote(myCommand); ConsoleExec(myCommand); but nothing works :( Thanks for youy help! |
-- YourLuaFile.lua --
function something_OnLoad() SLASH_YOURCOMMAND = "/raresist"; -- you can add multiple comands SLASH_YOURCOMMAND2 = "/raresist2"; -- you can add multiple comands SlashCmdList["CMDLIST"] = CmdFunction; end; function CmdFunction(cmd) if (cmd == "Something") then DoSomething; -- can be a function or a simple action like emote end; end; -- Finish -- Hope it helps :P Cheers |
Thanks for your reply ProfOak !
Sorry, I wasn't accurate enough. I know how to create slash-cmd in my addons but I would like to create a library of slash-cmd created and used in other addons (like /dcrshow for Decursive, /raresist for CTRA resist list, etc...). This could be done in macros (by creating a macro and fill it with /raresist for example) but I already have tons of macro and I don't want to fill my screen with all of theses macros.). Another solution could be to put the desired slash-cmd in the chat frame and then "apply/send/validate" the chat frame... but I don't know how to "apply" the chat frame :( |
It sounds like you are trying to run the slash commands from another mod, from inside one of your own mods? I don't really understand scope yet, need to do some reading I guess, but since slash commands in the other mods are just pointing at functions, can your mod just not call those functions instead of the slash commands pointing at them?
|
I was trying to build a *customizable* slash-cmd library. A place where users can store (exceute) and call some useful slash-cmd.
I recently tried: Code:
local myCommand = "/abs" -- test |
I use the following ... not sure anymore where I found that code
Quote:
|
Yeah, it works :)
Thx Sariash! |
Also with slash commands, some mods have it, if you type the /command twice it will close the window, how is this possible??
|
Quote:
|
All times are GMT -6. The time now is 10:50 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI