Mercurial > wow > inventory
comparison Plugins/ItemCountAddons/DataStore (current account only).lua @ 160:08b887885bd5
Forgot to include guilds in the ?DataStore (current account only)? item count plugin.
author | Zerotorescue |
---|---|
date | Sat, 22 Jan 2011 21:30:02 +0100 |
parents | de18ef96983b |
children |
comparison
equal
deleted
inserted
replaced
159:d45806866255 | 160:08b887885bd5 |
---|---|
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 guildName and type(guildName) == "table" then | |
27 disabledGuilds = guildName; | |
28 else | |
29 if not state then | |
30 disabledGuilds[guildName] = true; | |
31 else | |
32 disabledGuilds[guildName] = nil; | |
33 end | |
34 end | |
35 end | |
2 | 36 |
3 local function GetTotalCount(itemId) | 37 local function GetTotalCount(itemId) |
4 local realm = GetRealmName(); | 38 local realm = GetRealmName(); |
5 | 39 |
6 local totalCount = 0; | 40 local totalCount = 0; |
12 bag = (bag or 0); bank = (bank or 0); | 46 bag = (bag or 0); bank = (bank or 0); |
13 local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId) or 0; | 47 local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId) or 0; |
14 local mail = DataStore:GetMailItemCount(character, itemId) or 0; | 48 local mail = DataStore:GetMailItemCount(character, itemId) or 0; |
15 | 49 |
16 totalCount = totalCount + bag + bank + auctionHouse + mail; | 50 totalCount = totalCount + bag + bank + auctionHouse + mail; |
51 end | |
52 | |
53 local guilds = {}; | |
54 | |
55 -- Process all accounts | |
56 for accountName in pairs(DataStore:GetAccounts()) do | |
57 -- Process all guilds | |
58 for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do | |
59 if not guilds[guildName] and not disabledGuilds[guildName] then | |
60 -- We don't want itemcounts from a single guild to be counted twice, so first to present data wins | |
61 | |
62 guilds[guildName] = true; | |
63 | |
64 local guild = DataStore:GetGuildBankItemCount(guild, itemId) or 0; | |
65 | |
66 totalCount = totalCount + guild; | |
67 end | |
68 end | |
17 end | 69 end |
18 | 70 |
19 return totalCount or -1; | 71 return totalCount or -1; |
20 end | 72 end |
21 | 73 |
32 | 84 |
33 local function IsEnabled() | 85 local function IsEnabled() |
34 return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount); | 86 return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount); |
35 end | 87 end |
36 | 88 |
37 IMRegisterItemCountAddon("DataStore (current account only)", GetTotalCount, GetCharacterCount, IsEnabled); | 89 IMRegisterItemCountAddon("DataStore (current account only)", GetTotalCount, GetCharacterCount, IsEnabled, nil, GetGuildNames, SetGuildState); |
38 | 90 |
39 end | 91 end |