WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Using GetBindingKey() on MultiActionBars (https://www.wowinterface.com/forums/showthread.php?t=57211)

DashingSplash 06-18-19 08:25 AM

Using GetBindingKey() on MultiActionBars
 
Hi,

I am currently having trouble with GetBindingKey() when trying to fetch the keybinds of the Multi Action Bars. Below is a sample code of my current AddOn.

Code:

local dashingDismount = CreateFrame("Frame")

function dashingBindings()
        local buttonName
        local actionType, id, _, actionName
        local key1, key2
        local ActionBars = {"Action","MultiBarBottomLeft","MultiBarBottomRight","MultiBarLeft","MultiBarRight"}
       
        for bar = 1, #ActionBars do
                for i = 1, 12 do
                        buttonName = ActionBars[bar] .. "Button" .. i
                                               
                        actionType, id, _ = GetActionInfo(_G[buttonName].action)
                        actionName = GetSpellInfo(id)

                        print(buttonName)

                        key1, key2 = GetBindingKey(buttonName)

                    if key1 ~= nil then
                                print(key1)
                    end
                    if key2 ~= nil then
                                print(key2)
                    end
                end
        end
end

local function dashingInit(self, event, ...)
        dashingBindings()
end

dashingDismount:RegisterEvent("PLAYER_LOGIN")
dashingDismount:SetScript("OnEvent", dashingInit)

The code only manages to print(key1) for ActionButton1 to ActionButton12. MultiBarBottomLeftButton1 and beyond do not get to the print() at all. Am I missing something obvious?

MunkDev 06-18-19 07:43 PM

Not sure why you assumed that the button names would correspond to the binding names,
but e.g. MultiBarBottomLeftButton1 is actually MULTIACTIONBAR1BUTTON1 in the binding manifest.
ActionButton1 just happens to correspond to ACTIONBUTTON1, but they are not the same.

DashingSplash 06-19-19 12:33 PM

Quote:

Originally Posted by MunkDev (Post 332424)
Not sure why you assumed that the button names would correspond to the binding names,
but e.g. MultiBarBottomLeftButton1 is actually MULTIACTIONBAR1BUTTON1 in the binding manifest.
ActionButton1 just happens to correspond to ACTIONBUTTON1, but they are not the same.

I made that assumption since the examples that I have seen uses them. However, I have tried and GetBindingKey() seems to be case sensitive: ActionButton1 works, while ACTIONBUTTON1 and any other variation does not.

After an hour of tinkering and trial-and-error I simply can't get MULTIACTIONBAR1BUTTON1 or MultiActionBar1Button1 to work.

With the following code I also only managed to get it to work with ActionButton1:

Code:

local function dashingBindings(low, high)
        for i=low,high do
                local Button
                local actionType, id, _
                local actionName
                local command, _, key1, key2 = GetBinding(i)
               
                if not command:find("HEADER_BLANK") then
                        print(command)
               
                        Button = string.gsub(_G["BINDING_NAME_" .. command], " ", "")
                       
                        print(Button)
                        if _G[Button] ~= nil then
                                actionType, id, _ = GetActionInfo(ActionButton_CalculateAction(_G[Button]))
                                actionName = GetSpellInfo(id)
               
                                if key1 ~= nil then
                                        print(key1)
                                end
                                if key2 ~= nil then
                                        print(key2)
                                end
                        end       
                end       
        end
end

local function dashingInit(self, event, ...)
        dashingBindings(31,42)
        dashingBindings(74,121)
end

The problem here is that Button = string.gsub(_G["BINDING_NAME_" .. command], " ", "") will produce the string BottomLeftActionButton1 while the variable "command" will contain the string MULTIACTIONBAR1BUTTON1. Not been able to utilize "command" with the GetBindingKey() function.

I seemingly can't get it to work at all, so if you have any suggestions where to go from here that would be great. If anyone else has any ideas, feel free to post them.


All times are GMT -6. The time now is 09:01 PM.

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