Evangarstorm`s blog post

Go to Homepage
#WOW  29.7.2024   LUA code for keybindings
function getMyKeyBind(myspellname)
    if myspellname ~= nil then
        local wantedSpell = C_Spell.GetSpellInfo(myspellname)
        local bindstring = ""
        if wantedSpell ~= nil then
            local wantedSpellID = wantedSpell.spellID
            if C_ActionBar.HasSpellActionButtons(wantedSpellID) then
                for i = 1, 120 do
                    local actionType, spellID, subType = GetActionInfo(i)
                    if spellID == wantedSpellID then
                        local slotID = i
                        local action = slotID
                        local modact = 1 + (action - 1) % 12
                        if name == 'ExtraActionButton1' then
                            bindstring = 'EXTRAACTIONBUTTON1'
                        elseif action < 25 or action > 72 then
                            bindstring = 'ACTIONBUTTON' .. modact
                        elseif action < 73 and action > 60 then
                            bindstring = 'MULTIACTIONBAR1BUTTON' .. modact
                        elseif action < 61 and action > 48 then
                            bindstring = 'MULTIACTIONBAR2BUTTON' .. modact
                        elseif action < 49 and action > 36 then
                            bindstring = 'MULTIACTIONBAR4BUTTON' .. modact
                        elseif action < 37 and action > 24 then
                            bindstring = 'MULTIACTIONBAR3BUTTON' .. modact
                        end
                        local keyBind = GetBindingKey(bindstring)
                        local search1 = ""
                        local search2 = ""
                        search1 = string.find(keyBind, "SHIFT")
                        search2 = string.find(keyBind, "ALT")
                        if search1 ~= nil then
                            keyBind = keyBind:gsub("SHIFT", "s")
                        end
                        if search2 ~= nil then
                            keyBind = keyBind:gsub("ALT", "a")
                        end
                        return keyBind
                    end
                end
            end
        end
        if wantedSpell == nil then
            return "err"
        end
    end
end

 

Go to Homepage