annotate Plugins/ItemCountAddons/DataStore (current account only).lua @ 119:dc6f405c1a5d

Now resizing the mover frame based on text size. addon.Locations table now uses location names as value, rather than random numbers. Added proper Merchant restocking support. Please note this currently doesn?t take the bonus queue nor the min crafting queue options into account.
author Zerotorescue
date Sat, 15 Jan 2011 17:03:05 +0100
parents de18ef96983b
children 08b887885bd5
rev   line source
Zerotorescue@17 1 do
Zerotorescue@17 2
Zerotorescue@17 3 local function GetTotalCount(itemId)
Zerotorescue@17 4 local realm = GetRealmName();
Zerotorescue@17 5
Zerotorescue@17 6 local totalCount = 0;
Zerotorescue@17 7
Zerotorescue@17 8 -- Process all charracters on this account (GetCharacters defaults to THIS_ACCOUNT)
Zerotorescue@17 9 for characterName, character in pairs(DataStore:GetCharacters(realm, nil)) do
Zerotorescue@17 10 -- Get only useful info (currency / gear shouldn't contain the stuff we are interested in)
Zerotorescue@118 11 local bag, bank = DataStore:GetContainerItemCount(character, itemId);
Zerotorescue@118 12 bag = (bag or 0); bank = (bank or 0);
Zerotorescue@54 13 local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId) or 0;
Zerotorescue@54 14 local mail = DataStore:GetMailItemCount(character, itemId) or 0;
Zerotorescue@17 15
Zerotorescue@17 16 totalCount = totalCount + bag + bank + auctionHouse + mail;
Zerotorescue@17 17 end
Zerotorescue@17 18
Zerotorescue@17 19 return totalCount or -1;
Zerotorescue@17 20 end
Zerotorescue@17 21
Zerotorescue@17 22 local function GetCharacterCount(itemId)
Zerotorescue@17 23 local character = DataStore:GetCharacter();
Zerotorescue@17 24
Zerotorescue@118 25 local bag, bank = DataStore:GetContainerItemCount(character, itemId);
Zerotorescue@118 26 bag = (bag or 0); bank = (bank or 0);
Zerotorescue@54 27 local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId) or 0;
Zerotorescue@54 28 local mail = DataStore:GetMailItemCount(character, itemId) or 0;
Zerotorescue@17 29
Zerotorescue@17 30 return bag, bank, auctionHouse, mail;
Zerotorescue@17 31 end
Zerotorescue@17 32
Zerotorescue@17 33 local function IsEnabled()
Zerotorescue@17 34 return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount);
Zerotorescue@17 35 end
Zerotorescue@17 36
Zerotorescue@17 37 IMRegisterItemCountAddon("DataStore (current account only)", GetTotalCount, GetCharacterCount, IsEnabled);
Zerotorescue@17 38
Zerotorescue@17 39 end