So, I am trying to create a LUA function to count the number of a specific item, the problem that I am coming up with is if there are stacks of the item in more than one bag.
I see two options, I can store the item count for each bag, and add those 5 numbers to get the total item count, or I can reset the item count to 0 and call countItem for every bag on every BAG_UPDATE event. I'm not a huge fan of either solution, but don't see a better way. Any suggestions?Code:local function countItem(bag, item) for slot = 0, GetContainerNumSlots(bag) do local itemid = GetContainerItemID(bag, slot) if(item == itemid) then --Increment the item count here using GetContainerItemInfo end end end