annotate ItemCountAddons/DataStore (with guilds).lua @ 31:e732843b16d2 v0.1.6-BETA

Added an info box to the top of the general group. Removed the ?Don't queue when below threshold?, this is now default (can?t make it too complicated). Implemented working functionality for virtual groups. ?Include in local item data? can now be overridden in every group. Added help text at the replenishing stock indicating how auction values are used when queueing. The tabs ?add items? and ?current items? will now be hidden rather than disabled when you have a virtual group selected. The auction value/price threshold for items will now be used when queueing items.
author Zerotorescue
date Sat, 30 Oct 2010 23:04:45 +0200
parents 8f5c02113c5c
children 06fee4208bf2
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 local guilds = {};
Zerotorescue@17 9
Zerotorescue@17 10 -- Process all accounts
Zerotorescue@17 11 for accountName in pairs(DataStore:GetAccounts()) do
Zerotorescue@17 12
Zerotorescue@17 13 -- Process all charracters
Zerotorescue@17 14 for characterName, character in pairs(DataStore:GetCharacters(realm, accountName)) do
Zerotorescue@17 15 -- Get only useful info (currency / gear shouldn't contain the stuff we are interested in)
Zerotorescue@17 16 local bag, bank = DataStore:GetContainerItemCount(character, itemId);
Zerotorescue@17 17 local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId);
Zerotorescue@17 18 local mail = DataStore:GetMailItemCount(character, itemId);
Zerotorescue@17 19
Zerotorescue@17 20 totalCount = totalCount + bag + bank + auctionHouse + mail;
Zerotorescue@17 21 end
Zerotorescue@17 22
Zerotorescue@17 23 -- Process all guilds
Zerotorescue@17 24 for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do
Zerotorescue@17 25 if not guilds[guildName] then
Zerotorescue@17 26 -- We don't want itemcounts from a single guild to be counted twice, so first to present data wins
Zerotorescue@17 27
Zerotorescue@17 28 guilds[guildName] = true;
Zerotorescue@17 29
Zerotorescue@17 30 local guild = DataStore:GetGuildBankItemCount(guild, itemId);
Zerotorescue@17 31
Zerotorescue@17 32 totalCount = totalCount + guild;
Zerotorescue@17 33 end
Zerotorescue@17 34 end
Zerotorescue@17 35 end
Zerotorescue@17 36
Zerotorescue@17 37 return totalCount or -1;
Zerotorescue@17 38 end
Zerotorescue@17 39
Zerotorescue@17 40 local function GetCharacterCount(itemId)
Zerotorescue@17 41 local character = DataStore:GetCharacter();
Zerotorescue@17 42
Zerotorescue@17 43 local bag, bank = DataStore:GetContainerItemCount(character, itemId);
Zerotorescue@17 44 local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId);
Zerotorescue@17 45 local mail = DataStore:GetMailItemCount(character, itemId);
Zerotorescue@17 46
Zerotorescue@17 47 return bag, bank, auctionHouse, mail;
Zerotorescue@17 48 end
Zerotorescue@17 49
Zerotorescue@17 50 local function IsEnabled()
Zerotorescue@17 51 return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount);
Zerotorescue@17 52 end
Zerotorescue@17 53
Zerotorescue@17 54 IMRegisterItemCountAddon("DataStore (with guilds)", GetTotalCount, GetCharacterCount, IsEnabled);
Zerotorescue@17 55
Zerotorescue@17 56 end