annotate ItemCountAddons/DataStore (current account only).lua @ 30:8177b5bcb883

Added tag ?NYI? to the ?Alert when below minimum? option. Added ?Don't queue when below threshold? option. This isn?t functional yet, just a place holder to indicate it will be implemented at a later time. Added initial functionality for ?virtual? groups (feel free to suggest a better name :P), with these groups you can override the defaults for multiple groups. By default, settings will be retrieved as CURRENT_GROUP -> DEFAULTS, with this it can become CURRENT_GROUP -> VIRTUAL_GROUP -> DEFAULTS. This will come in handy when managing a lot of groups. Full functionality is not yet implemented, it is just a placeholder to indicate it will be added. Reduced the softmax for the restock target option from 1000 to 100 to make the slider actually useful. You can still enter a value of upto 100.000 in the edit box below.
author Zerotorescue
date Fri, 29 Oct 2010 13:43:41 +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 -- Process all charracters on this account (GetCharacters defaults to THIS_ACCOUNT)
Zerotorescue@17 9 for characterName, character in pairs(DataStore:GetCharacters(realm, nil)) do
Zerotorescue@17 10 -- Get only useful info (currency / gear shouldn't contain the stuff we are interested in)
Zerotorescue@17 11 local bag, bank = DataStore:GetContainerItemCount(character, itemId);
Zerotorescue@17 12 local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId);
Zerotorescue@17 13 local mail = DataStore:GetMailItemCount(character, itemId);
Zerotorescue@17 14
Zerotorescue@17 15 totalCount = totalCount + bag + bank + auctionHouse + mail;
Zerotorescue@17 16 end
Zerotorescue@17 17
Zerotorescue@17 18 return totalCount or -1;
Zerotorescue@17 19 end
Zerotorescue@17 20
Zerotorescue@17 21 local function GetCharacterCount(itemId)
Zerotorescue@17 22 local character = DataStore:GetCharacter();
Zerotorescue@17 23
Zerotorescue@17 24 local bag, bank = DataStore:GetContainerItemCount(character, itemId);
Zerotorescue@17 25 local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId);
Zerotorescue@17 26 local mail = DataStore:GetMailItemCount(character, itemId);
Zerotorescue@17 27
Zerotorescue@17 28 return bag, bank, auctionHouse, mail;
Zerotorescue@17 29 end
Zerotorescue@17 30
Zerotorescue@17 31 local function IsEnabled()
Zerotorescue@17 32 return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount);
Zerotorescue@17 33 end
Zerotorescue@17 34
Zerotorescue@17 35 IMRegisterItemCountAddon("DataStore (current account only)", GetTotalCount, GetCharacterCount, IsEnabled);
Zerotorescue@17 36
Zerotorescue@17 37 end