Quantcast
How to execute a slash-command? - WoWInterface
Thread Tools Display Modes
10-08-06, 11:04 AM   #1
Zax
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 75
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!
  Reply With Quote
10-09-06, 02:56 AM   #2
ProfOak
A Cyclonian
Join Date: Oct 2005
Posts: 47
-- 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
  Reply With Quote
10-09-06, 03:18 AM   #3
Zax
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 75
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

Last edited by Zax : 10-09-06 at 03:28 AM.
  Reply With Quote
10-11-06, 12:36 AM   #4
Himar
A Murloc Raider
Join Date: Oct 2006
Posts: 4
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?
  Reply With Quote
10-11-06, 03:42 AM   #5
Zax
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 75
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
  Reply With Quote
10-11-06, 04:18 AM   #6
Sariash
A Fallenroot Satyr
Join Date: Jan 2005
Posts: 23
I use the following ... not sure anymore where I found that code
DEFAULT_CHAT_FRAME.editBox:SetText("/raresist") ChatEdit_SendText(DEFAULT_CHAT_FRAME.editBox, 0)
  Reply With Quote
10-13-06, 12:46 AM   #7
Zax
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 75
Yeah, it works
Thx Sariash!
  Reply With Quote
10-13-06, 01:26 PM   #8
Xerogen
A Deviate Faerie Dragon
 
Xerogen's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2006
Posts: 16
Also with slash commands, some mods have it, if you type the /command twice it will close the window, how is this possible??
  Reply With Quote
10-23-06, 02:14 AM   #9
Zeksie
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 24
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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to execute a slash-command?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off