view 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
line wrap: on
line source
do
	
	local function GetTotalCount(itemId)
		local realm = GetRealmName();
		
		local totalCount = 0;
		
		-- Process all charracters on this account (GetCharacters defaults to THIS_ACCOUNT)
		for characterName, character in pairs(DataStore:GetCharacters(realm, nil)) do
			-- Get only useful info (currency / gear shouldn't contain the stuff we are interested in)
			local bag, bank = DataStore:GetContainerItemCount(character, itemId);
			local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId);
			local mail = DataStore:GetMailItemCount(character, itemId);
			
			totalCount = totalCount + bag + bank + auctionHouse + mail;
		end
		
		return totalCount or -1;
	end
	
	local function GetCharacterCount(itemId)
		local character = DataStore:GetCharacter();
		
		local bag, bank = DataStore:GetContainerItemCount(character, itemId);
		local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId);
		local mail = DataStore:GetMailItemCount(character, itemId);
		
		return bag, bank, auctionHouse, mail;
	end
	
	local function IsEnabled()
		return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount);
	end
	
	IMRegisterItemCountAddon("DataStore (current account only)", GetTotalCount, GetCharacterCount, IsEnabled);
	
end