View Single Post
10-29-20, 03:55 PM   #1
benots4
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 20
Global Environmental Variables nil

I have a snipit of code I got from this site has broken by pre patch. The error I get now is nil value for ActionButton_GetPagedID(button).. button being nil. Seems like the environment function is returning a table of nil. local button = _G[barName .. 'Button' .. i] button is a table but nil. Have the Global environments changed? Know a way around this??



Original code
Code:
local ActionBars = {'Action','MultiBarBottomLeft','MultiBarBottomRight','MultiBarRight','MultiBarLeft'}
function PrintActions()
    for _, barName in pairs(ActionBars) do
        for i = 1, 12 do
            local button = _G[barName .. 'Button' .. i]
            local slot = ActionButton_GetPagedID(button) or ActionButton_CalculateAction(button) or button:GetAttribute('action') or 0
            if HasAction(slot) then
                local actionName, _
                local actionType, id = GetActionInfo(slot)
                if actionType == 'macro' then _, _ , id = GetMacroSpell(id) end
                if actionType == 'item' then
                    actionName = GetItemInfo(id)
                elseif actionType == 'spell' or (actionType == 'macro' and id) then
                    actionName = GetSpellInfo(id)
                end
                if actionName then
                    print(button:GetName(), actionType, (GetSpellLink(id)), actionName)
                end
            end
        end
    end
end
  Reply With Quote