WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Need help setting a macro icon. (https://www.wowinterface.com/forums/showthread.php?t=58290)

ujellyx 10-15-20 09:48 AM

Need help setting a macro icon.
 
I've macro'd "/click ExtraActionButton1" in order to have a macro for various world quests and quests in general. Unfortunately the macro itself doesn't get the icon or tooltip of the respective item/spell.

I want to set the macro icon dynamically depending on the current item/spell that's in the ExtraActionButton1.

What I've come up with so far is:

Code:

local frame = CreateFrame("FRAME", "SetMacroIconForEAB1");
frame:RegisterEvent("UPDATE_EXTRA_ACTIONBAR");
local function eventHandler(self, event, ...)
        for mi = 1, _G.MAX_ACCOUNT_MACROS + _G.MAX_CHARACTER_MACROS do
                local str = "EAB1"
                local name, icon, body = GetMacroInfo(mi)
                        if string.find(body,str) then
                                local button = _G['ExtraActionButton1']
                                local slot = ActionButton_GetPagedID(button) or ActionButton_CalculateAction(button) or button:GetAttribute('action') or 0
                                local actionType, id, _ = GetActionInfo(slot)
                                local actionName = GetSpellInfo(id)
                                print(aname,actionName)
                                SetMacroSpell(name,actionName)
                                break
                        end
        end
end
frame:SetScript("OnEvent", eventHandler);

That doesn't work however. I suspect that the ExtraActionButton1 isn't accessible from the above lua code. Any suggestions?

Edit: Found out that the slot for the ExtraActionButton1 is 121. Tried with manually defining slot as 121, but GetActionInfo just returns "nil".


All times are GMT -6. The time now is 08:12 AM.

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