View Single Post
05-03-21, 06:04 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Commands are stored in the SlashCmdList table. You'll need the token the addon uses to register the command.
For example, you can open BigWigs' options window by calling this.
Code:
SlashCmdList.BigWigs()
To send arguments, just pass them as a single string to the function, similar to this.
Code:
SlashCmdList.TOKEN("args")


While you can also access commands using hash_SlashCmdList, slash commands are often localized, meaning your code probably won't work in other languages. SlashCmdList is more stable as tokens are not supposed to be localized.



If you insist on using macro buttons, you can inject links using concatenation or formatting. Note this is also susceptible to localization.
For example, this'll make you send the link for Hearthstone in /say.
Lua Code:
  1. local frame = CreateFrame("Button", nil, region, "SecureActionButtonTemplate")
  2. frame:SetAllPoints(region)
  3. frame:SetAttribute("type","macro")
  4. frame:SetAttribute("macrotext", "/say " .. select(2, GetItemInfo(6948)))
  5. frame:RegisterForClicks("AnyDown")
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 05-05-21 at 09:51 AM.
  Reply With Quote