Mercurial > wow > itemauditor
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 151:e06bf0b64caa | 152:cbb427a8d5a5 |
|---|---|
| 198 function ItemAuditor:BankFrameChanged(event) | 198 function ItemAuditor:BankFrameChanged(event) |
| 199 bankOpen = (event == 'BANKFRAME_OPENED') | 199 bankOpen = (event == 'BANKFRAME_OPENED') |
| 200 ItemAuditor:UpdateCurrentInventory() | 200 ItemAuditor:UpdateCurrentInventory() |
| 201 end | 201 end |
| 202 | 202 |
| 203 local function getTotalFromBagsAndInventory(searchID) | |
| 204 local character = DataStore:GetCharacter() | |
| 205 local bags, bank = DataStore:GetContainerItemCount(character, searchID) | |
| 206 local count = (bags or 0) | |
| 207 if bankOpen then | |
| 208 count = count + bank | |
| 209 end | |
| 210 count = count + (DataStore:GetInventoryItemCount(character, searchID) or 0) | |
| 211 | |
| 212 return count | |
| 213 end | |
| 214 | |
| 203 local function scanBag(bagID, i) | 215 local function scanBag(bagID, i) |
| 204 bagSize=GetContainerNumSlots(bagID) | 216 local bag = DataStore:GetContainer(DataStore:GetCharacter(), bagID) |
| 205 for slotID = 0, bagSize do | 217 if bag then |
| 206 local link= GetContainerItemLink(bagID, slotID); | 218 for slotID = 0, bag.size do |
| 207 itemID = link and Utils.GetItemID(link) | 219 local itemID = DataStore:GetSlotInfo(bag, slotID); |
| 208 | 220 |
| 209 if link and itemID and i[itemID] == nil then | 221 if itemID and i[itemID] == nil then |
| 210 i[itemID] = GetItemCount(itemID, bankOpen); | 222 i[itemID] = getTotalFromBagsAndInventory(itemID); |
| 211 end | 223 end |
| 212 end | 224 end |
| 213 end | 225 end |
| 214 | 226 end |
| 227 | |
| 228 local NUM_EQUIPMENT_SLOTS = 19 | |
| 215 function ItemAuditor:GetCurrentInventory() | 229 function ItemAuditor:GetCurrentInventory() |
| 216 local i = {} | 230 local i = {} |
| 217 local bagID | 231 local bagID |
| 218 local slotID | 232 local slotID |
| 219 | 233 |
| 223 | 237 |
| 224 if bankOpen then | 238 if bankOpen then |
| 225 scanBag(BANK_CONTAINER, i) | 239 scanBag(BANK_CONTAINER, i) |
| 226 for bagID = NUM_BAG_SLOTS+1, NUM_BANKBAGSLOTS do | 240 for bagID = NUM_BAG_SLOTS+1, NUM_BANKBAGSLOTS do |
| 227 scanBag(bagID, i) | 241 scanBag(bagID, i) |
| 242 end | |
| 243 end | |
| 244 | |
| 245 local character = DataStore:GetCharacter() | |
| 246 for slotID = 1, NUM_EQUIPMENT_SLOTS do | |
| 247 local link = DataStore:GetInventoryItem(character, slotID) | |
| 248 itemID = link and Utils.GetItemID(link) | |
| 249 | |
| 250 if link and itemID and i[itemID] == nil then | |
| 251 i[itemID] = getTotalFromBagsAndInventory(itemID); | |
| 228 end | 252 end |
| 229 end | 253 end |
| 230 | 254 |
| 231 return {items = i, money = GetMoney()} | 255 return {items = i, money = GetMoney()} |
| 232 end | 256 end |
| 561 | 585 |
| 562 | 586 |
| 563 function ItemAuditor:WatchBags() | 587 function ItemAuditor:WatchBags() |
| 564 if self.watch_handle == nil then | 588 if self.watch_handle == nil then |
| 565 ItemAuditor:UpdateCurrentInventory() | 589 ItemAuditor:UpdateCurrentInventory() |
| 566 self.watch_handle = self:RegisterBucketEvent({"BAG_UPDATE", "PLAYER_MONEY"}, 0.3, "UpdateAudit") | 590 self.watch_handle = self:RegisterBucketEvent({"BAG_UPDATE", "PLAYER_MONEY", "UNIT_INVENTORY_CHANGED"}, 0.3, "UpdateAudit") |
| 567 end | 591 end |
| 568 end | 592 end |
| 569 | 593 |
| 570 function ItemAuditor:UnwatchBags() | 594 function ItemAuditor:UnwatchBags() |
| 571 if self.watch_handle ~= nil then | 595 if self.watch_handle ~= nil then |
