Mercurial > wow > itemauditor
diff Core.lua @ 152:cbb427a8d5a5
Fixed a bug where your equipped items were not counted as items in your inventory. If you replaced an equipped item and one of them had a cost associated, it would transfer the value between the two.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Mon, 29 Nov 2010 11:25:55 -0800 |
parents | 1db61fa6be07 |
children | 7ebe0a85d539 |
line wrap: on
line diff
--- a/Core.lua Sat Oct 30 15:14:55 2010 -0700 +++ b/Core.lua Mon Nov 29 11:25:55 2010 -0800 @@ -200,18 +200,32 @@ ItemAuditor:UpdateCurrentInventory() end +local function getTotalFromBagsAndInventory(searchID) + local character = DataStore:GetCharacter() + local bags, bank = DataStore:GetContainerItemCount(character, searchID) + local count = (bags or 0) + if bankOpen then + count = count + bank + end + count = count + (DataStore:GetInventoryItemCount(character, searchID) or 0) + + return count +end + local function scanBag(bagID, i) - bagSize=GetContainerNumSlots(bagID) - for slotID = 0, bagSize do - local link= GetContainerItemLink(bagID, slotID); - itemID = link and Utils.GetItemID(link) + local bag = DataStore:GetContainer(DataStore:GetCharacter(), bagID) + if bag then + for slotID = 0, bag.size do + local itemID = DataStore:GetSlotInfo(bag, slotID); - if link and itemID and i[itemID] == nil then - i[itemID] = GetItemCount(itemID, bankOpen); + if itemID and i[itemID] == nil then + i[itemID] = getTotalFromBagsAndInventory(itemID); + end end end end +local NUM_EQUIPMENT_SLOTS = 19 function ItemAuditor:GetCurrentInventory() local i = {} local bagID @@ -228,6 +242,16 @@ end end + local character = DataStore:GetCharacter() + for slotID = 1, NUM_EQUIPMENT_SLOTS do + local link = DataStore:GetInventoryItem(character, slotID) + itemID = link and Utils.GetItemID(link) + + if link and itemID and i[itemID] == nil then + i[itemID] = getTotalFromBagsAndInventory(itemID); + end + end + return {items = i, money = GetMoney()} end @@ -563,7 +587,7 @@ function ItemAuditor:WatchBags() if self.watch_handle == nil then ItemAuditor:UpdateCurrentInventory() - self.watch_handle = self:RegisterBucketEvent({"BAG_UPDATE", "PLAYER_MONEY"}, 0.3, "UpdateAudit") + self.watch_handle = self:RegisterBucketEvent({"BAG_UPDATE", "PLAYER_MONEY", "UNIT_INVENTORY_CHANGED"}, 0.3, "UpdateAudit") end end