• 0

    posted a message on GetContainerItemID only returning nil

    Disclaimer: Brand new to writing WoW addons.

     

    Basically trying to teach myself how to write addons, and the current task at hand is to cycle through all the items in my bags, and get the item level.

     

    The problem I have is when I call "GetContainerItemID", it just returns nil for every combination of bag and slot, even though I expect at least 5 of those slots, not to return nil

     

    local eventFrame = CreateFrame("FRAME");
    eventFrame:RegisterEvent("BAG_UPDATE");
    
    local function listBagItems ()
        for intBag=0,NUM_BAG_SLOTS do
            for intSlot=1, GetContainerNumSlots(intBag) do
                local intItem = GetContainerItemID(intBag, intSlot)
                print(intItem, intBag, intSlot)
            end
        end
    end
    
    local function eventHandler (self, event, arg)
        print ("Event Caught", event)
        if event == "BAG_UPDATE" then
            listBagItems()
        end    
    end
    
    eventFrame:SetScript("OnEvent", eventHandler);

    Hopefully someone can point me in the right direction, or at least point out my mistake?

     

    Tx in advance.

    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.