WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Using SetAttribute to bind tradeskill to button (https://www.wowinterface.com/forums/showthread.php?t=37295)

maltese 12-02-10 10:29 PM

Using SetAttribute to bind tradeskill to button
 
Is it possible to bind a tradeskill to a button using SetAttribute?

I've tried everything I know (which isn't much) to bind a tradeskill to a button in an addon. I can get any spell to work, but tradeskills are not working for some reason.

Code:

cdbutton:SetAttribute("type", "spell")
cdbutton:SetAttribute("spell", "Northrend Alchemy Research")

Using the spell ID of Northrend Alchemy Research doesn't work either.
So far what I've come up with is that tradeskills are not considered spells anymore, so I'm curious what I need to do to make the button work. Any ideas?

Torhal 12-03-10 12:46 AM

Make it a macro rather than a spell, with a text of "/cast Northrend Alchemy Research".

maltese 12-03-10 06:30 AM

That unfortunately does not work. With or without the alchemy window open.

I did however find a way to do it, but it requires knowing the index of the tradeskill you are trying to cast by using DoTradeSkill(). The issue is then all the sections have to be open to set an accurate index and I'm not sure it works with your second trade skill.

Xubera 12-03-10 07:58 AM

just to make sure, the macro :setattribute is tricky.

its
:SetAttribute("type","macro")
:SetAttribute("macrotext", "/cast ...")

took me forever to figure that one out ><

Saiket 12-03-10 08:17 AM

It's possible to cast tradeskill recipe spells from an action bar without the window open, and you could rig a button up for this, but unless you're willing to take over an action slot permanently, this trick won't work in combat. Here's a non-combat-only version that swaps actions around just long enough to cast your tradeskill:

Code:

cdbutton:SetAttribute("type", "action")
cdbutton:SetAttribute("action", 1)

cdbutton:SetScript("PreClick", function ()
  PickupSpell(60893) -- Northrend Alchemy Research
  PlaceAction(1)
end)
cdbutton:SetScript("PostClick", function ()
  PickupAction(1) -- Put previous action back
  ClearCursor()
end)

Make sure to disable that button in combat too or else the Pre/PostClicks will throw an action blocked error if clicked.


All times are GMT -6. The time now is 12:43 PM.

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