-
Posted by Omnius on Fri, 16 Apr 2010 01:40:57
I was wondering why I was seeing one of my bags show up in the list of items and I found that the inner loop needs to start at 1, not 0:
for slot = 1, GetContainerNumSlots(bag) do
Now I'm just wondering why it considers some White items to be Poor quality ...
-
Posted by jnwhiteh on Fri, 16 Apr 2010 07:10:20
Thanks for the heads up. The quality issue (I believe) is mentioned in the chapter, because the 'item quality' APIs are completely consistent with returns for common and poor quality items. If you find a better rationale, let me know =)
-
Posted by Omnius on Fri, 16 Apr 2010 13:23:32
Apparently it's not just white items showing up when the "Poor" button is selected, I get items of all qualities mixed in there - though not all existing items, the count changes when I select the "Common" quality. And some items with colored titles don't get the aura around them. I've DLed the 12-BagBuddy.zip and tried that (BTW, the title when that frame displays is "BagBuggy" 8^) which is actually what the text has you type in) and the results are the same, so it doesn't appear to be a typing error on my part, though I'm not discounting that possibility. My gut says it has something to do with the "shown" variable but I can't prove it ... Do parentheses affect parsing of boolean expressions in Lua? I might try throwing some of those in and see what happens. Overall an extremely instructive pair of books, thanks for them 8^).
-
Posted by jnwhiteh on Fri, 16 Apr 2010 14:05:15
Sounds like you're getting an error.. do you have Lua errors enabled?
-
Posted by Omnius on Fri, 16 Apr 2010 15:07:30
Yes, Lua errors are turned on - but the issue seems to be with the quality value returned by GetContainerItemInfo. I modified the loop as follows and seem to be getting the behavior I expect (hope the formatting doesn't get too scrambled):
for bag = 0, NUM_BAG_SLOTS do for slot = 1, GetContainerNumSlots(bag) do local texture, count, locked, _, readable, lootable, link = GetContainerItemInfo(bag, slot) if texture then local itemNum = tonumber(link:match("|Hitem:(%d+):")) local name,_,quality = GetItemInfo(itemNum) local shown = true if BagBuddy.qualityFilter then shown = shown and BagBuddy.filters[quality]:GetChecked() end if shown then if not items[itemNum] then items[itemNum] = { texture = texture, count = count, quality = quality, name = name, link = link, } else items[itemNum].count = items[itemNum].count + count end end end end end
Haven't tried it on all my toons yet 8^) but first tests show everything getting the right halo and showing up when the proper button is pushed.