comparison Plugins/ItemCountAddons/DataStore (with guilds).lua @ 156:314943963155

Added initial guild bank data excluding (for addons like DataStore). This setting is currently not stored on relog.
author Zerotorescue
date Sat, 22 Jan 2011 02:57:08 +0100
parents de18ef96983b
children
comparison
equal deleted inserted replaced
155:5081056cade1 156:314943963155
1 do 1 do
2 local disabledGuilds = {};
3
4 local function GetGuildNames()
5 local guilds = {};
6
7 local realm = GetRealmName();
8
9 -- Process all accounts
10 for accountName in pairs(DataStore:GetAccounts()) do
11 for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do
12
13 if disabledGuilds[guildName] then
14 guilds[guildName] = false;
15 else
16 guilds[guildName] = true;
17 end
18
19 end
20 end
21
22 return guilds;
23 end
24
25 local function SetGuildState(guildName, state)
26 if not state then
27 disabledGuilds[guildName] = true;
28 else
29 disabledGuilds[guildName] = nil;
30 end
31 end
2 32
3 local function GetTotalCount(itemId) 33 local function GetTotalCount(itemId)
4 local realm = GetRealmName(); 34 local realm = GetRealmName();
5 35
6 local totalCount = 0; 36 local totalCount = 0;
21 totalCount = totalCount + bag + bank + auctionHouse + mail; 51 totalCount = totalCount + bag + bank + auctionHouse + mail;
22 end 52 end
23 53
24 -- Process all guilds 54 -- Process all guilds
25 for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do 55 for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do
26 if not guilds[guildName] then 56 if not guilds[guildName] and not disabledGuilds[guildName] then
27 -- We don't want itemcounts from a single guild to be counted twice, so first to present data wins 57 -- We don't want itemcounts from a single guild to be counted twice, so first to present data wins
28 58
29 guilds[guildName] = true; 59 guilds[guildName] = true;
30 60
31 local guild = DataStore:GetGuildBankItemCount(guild, itemId) or 0; 61 local guild = DataStore:GetGuildBankItemCount(guild, itemId) or 0;
51 81
52 local function IsEnabled() 82 local function IsEnabled()
53 return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount); 83 return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount);
54 end 84 end
55 85
56 IMRegisterItemCountAddon("DataStore (with guilds)", GetTotalCount, GetCharacterCount, IsEnabled); 86 IMRegisterItemCountAddon("DataStore (with guilds)", GetTotalCount, GetCharacterCount, IsEnabled, nil, GetGuildNames, SetGuildState);
57 87
58 end 88 end