Thread Tools Display Modes
08-25-09, 11:28 PM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
/commands in xml onclicks

How would you put another addons /command on a button created with xml?

ive tried everything...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
08-25-09, 11:30 PM   #2
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
never mind think i figured it out....
RunSlashCmd("/command")
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
08-30-09, 09:59 AM   #3
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
RunSlashCmd isn't a function provided in the wow api. It's possible to make said function but it's just adding in an unnecessary middle-man.

All slash command handlers are stored in the SlashCmdList table. You just need to find the hash index of the command you want and run it as a function. i.e. if I wanted to call /stopwatch 30


Code:
SlashCmdList['STOPWATCH'](30) -- 30 second timer
  Reply With Quote
08-31-09, 10:11 AM   #4
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Actually.... add this nice little snippet to your lua and what i posted before becomes a valid function...

Also im trying to make calls to other addons slash commands not ones built into wow.

Code:
local function RunSlashCmd(cmd) 
	      local slash, rest = cmd:match("^(%S+)%s*(.-)$") 
	      for name in pairs(SlashCmdList) do 
	         local i = 1 
	         local slashCmd 
	         repeat 
	            slashCmd = _G["SLASH_"..name..i] 
	 
	            if slashCmd == slash then 
	               -- Call the handler  
	               SlashCmdList[name](rest) 
	               return true 
	            end 
	            i = i + 1 
	         until not slashCmd 
	      end 
	    end
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 08-31-09 at 10:14 AM.
  Reply With Quote
08-31-09, 02:16 PM   #5
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
All slash commands are stored in the SlashCmdList table, including 3rd party addons.
  Reply With Quote
08-31-09, 05:05 PM   #6
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by Waverian View Post
All slash commands are stored in the SlashCmdList table, including 3rd party addons.
You still have to do something like he posted, because the keys of SlashCmdList don't necessarily correspond to the slash command text.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » /commands in xml onclicks


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