WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   How to execute a slash-command? (https://www.wowinterface.com/forums/showthread.php?t=6467)

Zax 10-08-06 11:04 AM

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!

ProfOak 10-09-06 02:56 AM

-- 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

Zax 10-09-06 03:18 AM

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 :(

Himar 10-11-06 12:36 AM

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?

Zax 10-11-06 03:42 AM

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
if (not ChatFrameEditBox:IsVisible()) then
        ChatFrame_OpenChat(myCommand );
else
        ChatFrameEditBox:SetText(myCommand );
end;
ChatEdit_ParseText(ChatFrameEditBox,0);
ChatEdit_ParseText(ChatFrame1.editBox,0);
ChatEdit_OnEnterPressed();

but it returns me a framexml error :(

Sariash 10-11-06 04:18 AM

I use the following ... not sure anymore where I found that code
Quote:

DEFAULT_CHAT_FRAME.editBox:SetText("/raresist") ChatEdit_SendText(DEFAULT_CHAT_FRAME.editBox, 0)

Zax 10-13-06 12:46 AM

Yeah, it works :)
Thx Sariash!

Xerogen 10-13-06 01:26 PM

Also with slash commands, some mods have it, if you type the /command twice it will close the window, how is this possible??

Zeksie 10-23-06 02:14 AM

Quote:

Originally Posted by Xerogen
Also with slash commands, some mods have it, if you type the /command twice it will close the window, how is this possible??

That's up to the mod author to code it.


All times are GMT -6. The time now is 10:50 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI