# HG changeset patch # User Zerotorescue # Date 1295728202 -3600 # Node ID 08b887885bd5386ec8c19210973313c489da1610 # Parent d45806866255dc41398597806b05df0a73c89497 Forgot to include guilds in the ?DataStore (current account only)? item count plugin. diff -r d45806866255 -r 08b887885bd5 Plugins/ItemCountAddons/DataStore (current account only).lua --- a/Plugins/ItemCountAddons/DataStore (current account only).lua Sat Jan 22 19:28:02 2011 +0100 +++ b/Plugins/ItemCountAddons/DataStore (current account only).lua Sat Jan 22 21:30:02 2011 +0100 @@ -1,4 +1,38 @@ do + local disabledGuilds = {}; + + local function GetGuildNames() + local guilds = {}; + + local realm = GetRealmName(); + + -- Process all accounts + for accountName in pairs(DataStore:GetAccounts()) do + for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do + + if disabledGuilds[guildName] then + guilds[guildName] = false; + else + guilds[guildName] = true; + end + + end + end + + return guilds; + end + + local function SetGuildState(guildName, state) + if guildName and type(guildName) == "table" then + disabledGuilds = guildName; + else + if not state then + disabledGuilds[guildName] = true; + else + disabledGuilds[guildName] = nil; + end + end + end local function GetTotalCount(itemId) local realm = GetRealmName(); @@ -16,6 +50,24 @@ totalCount = totalCount + bag + bank + auctionHouse + mail; end + local guilds = {}; + + -- Process all accounts + for accountName in pairs(DataStore:GetAccounts()) do + -- Process all guilds + for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do + if not guilds[guildName] and not disabledGuilds[guildName] then + -- We don't want itemcounts from a single guild to be counted twice, so first to present data wins + + guilds[guildName] = true; + + local guild = DataStore:GetGuildBankItemCount(guild, itemId) or 0; + + totalCount = totalCount + guild; + end + end + end + return totalCount or -1; end @@ -34,6 +86,6 @@ return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount); end - IMRegisterItemCountAddon("DataStore (current account only)", GetTotalCount, GetCharacterCount, IsEnabled); + IMRegisterItemCountAddon("DataStore (current account only)", GetTotalCount, GetCharacterCount, IsEnabled, nil, GetGuildNames, SetGuildState); end