Zerotorescue@157
|
1 do
|
Zerotorescue@157
|
2 local disabledGuilds = {};
|
Zerotorescue@157
|
3
|
Zerotorescue@157
|
4 local function GetGuildNames()
|
Zerotorescue@157
|
5 local guilds = {};
|
Zerotorescue@157
|
6
|
Zerotorescue@157
|
7 local realm = GetRealmName();
|
Zerotorescue@157
|
8
|
Zerotorescue@157
|
9 -- Process all accounts
|
Zerotorescue@157
|
10 for accountName in pairs(DataStore:GetAccounts()) do
|
Zerotorescue@157
|
11 for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do
|
Zerotorescue@157
|
12
|
Zerotorescue@157
|
13 if disabledGuilds[guildName] then
|
Zerotorescue@157
|
14 guilds[guildName] = false;
|
Zerotorescue@157
|
15 else
|
Zerotorescue@157
|
16 guilds[guildName] = true;
|
Zerotorescue@157
|
17 end
|
Zerotorescue@157
|
18
|
Zerotorescue@157
|
19 end
|
Zerotorescue@157
|
20 end
|
Zerotorescue@157
|
21
|
Zerotorescue@157
|
22 return guilds;
|
Zerotorescue@157
|
23 end
|
Zerotorescue@157
|
24
|
Zerotorescue@157
|
25 local function SetGuildState(guildName, state)
|
Zerotorescue@157
|
26 if guildName and type(guildName) == "table" then
|
Zerotorescue@157
|
27 disabledGuilds = guildName;
|
Zerotorescue@157
|
28 else
|
Zerotorescue@157
|
29 if not state then
|
Zerotorescue@157
|
30 disabledGuilds[guildName] = true;
|
Zerotorescue@157
|
31 else
|
Zerotorescue@157
|
32 disabledGuilds[guildName] = nil;
|
Zerotorescue@157
|
33 end
|
Zerotorescue@157
|
34 end
|
Zerotorescue@157
|
35 end
|
Zerotorescue@157
|
36
|
Zerotorescue@157
|
37 local function GetTotalCount(itemId)
|
Zerotorescue@157
|
38 local realm = GetRealmName();
|
Zerotorescue@157
|
39
|
Zerotorescue@157
|
40 local totalCount = 0;
|
Zerotorescue@157
|
41
|
Zerotorescue@157
|
42 local guilds = {};
|
Zerotorescue@157
|
43
|
Zerotorescue@157
|
44 -- Process all accounts
|
Zerotorescue@157
|
45 for accountName in pairs(DataStore:GetAccounts()) do
|
Zerotorescue@157
|
46 -- Process all charracters
|
Zerotorescue@157
|
47 for characterName, character in pairs(DataStore:GetCharacters(realm, accountName)) do
|
Zerotorescue@157
|
48 -- Get only useful info (currency / gear shouldn't contain the stuff we are interested in)
|
Zerotorescue@157
|
49 local bag, bank = DataStore:GetContainerItemCount(character, itemId);
|
Zerotorescue@157
|
50 bag = (bag or 0); bank = (bank or 0);
|
Zerotorescue@157
|
51 local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId) or 0;
|
Zerotorescue@157
|
52 local mail = DataStore:GetMailItemCount(character, itemId) or 0;
|
Zerotorescue@157
|
53
|
Zerotorescue@157
|
54 totalCount = totalCount + bag + bank + auctionHouse + mail;
|
Zerotorescue@157
|
55 end
|
Zerotorescue@157
|
56
|
Zerotorescue@157
|
57 -- Process all guilds
|
Zerotorescue@157
|
58 for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do
|
Zerotorescue@157
|
59 if not guilds[guildName] and not disabledGuilds[guildName] then
|
Zerotorescue@157
|
60 -- We don't want itemcounts from a single guild to be counted twice, so first to present data wins
|
Zerotorescue@157
|
61
|
Zerotorescue@157
|
62 guilds[guildName] = true;
|
Zerotorescue@157
|
63
|
Zerotorescue@157
|
64 local guild = DataStore:GetGuildBankItemCount(guild, itemId) or 0;
|
Zerotorescue@157
|
65
|
Zerotorescue@157
|
66 totalCount = totalCount + guild;
|
Zerotorescue@157
|
67 end
|
Zerotorescue@157
|
68 end
|
Zerotorescue@157
|
69 end
|
Zerotorescue@157
|
70
|
Zerotorescue@157
|
71 return totalCount or -1;
|
Zerotorescue@157
|
72 end
|
Zerotorescue@157
|
73
|
Zerotorescue@157
|
74 local function GetCharacterCount(itemId)
|
Zerotorescue@157
|
75 local character = DataStore:GetCharacter();
|
Zerotorescue@157
|
76
|
Zerotorescue@157
|
77 local bag, bank = DataStore:GetContainerItemCount(character, itemId);
|
Zerotorescue@157
|
78 bag = (bag or 0); bank = (bank or 0);
|
Zerotorescue@157
|
79 local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId) or 0;
|
Zerotorescue@157
|
80 local mail = DataStore:GetMailItemCount(character, itemId) or 0;
|
Zerotorescue@157
|
81
|
Zerotorescue@157
|
82 return bag, bank, auctionHouse, mail;
|
Zerotorescue@157
|
83 end
|
Zerotorescue@157
|
84
|
Zerotorescue@157
|
85 local function IsEnabled()
|
Zerotorescue@157
|
86 return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount);
|
Zerotorescue@157
|
87 end
|
Zerotorescue@157
|
88
|
Zerotorescue@157
|
89 IMRegisterItemCountAddon("DataStore (all accounts)", GetTotalCount, GetCharacterCount, IsEnabled, nil, GetGuildNames, SetGuildState);
|
Zerotorescue@157
|
90
|
Zerotorescue@157
|
91 end
|