view ItemCountAddons/DataStore (without guilds).lua @ 31:e732843b16d2 v0.1.6-BETA

Added an info box to the top of the general group. Removed the ?Don't queue when below threshold?, this is now default (can?t make it too complicated). Implemented working functionality for virtual groups. ?Include in local item data? can now be overridden in every group. Added help text at the replenishing stock indicating how auction values are used when queueing. The tabs ?add items? and ?current items? will now be hidden rather than disabled when you have a virtual group selected. The auction value/price threshold for items will now be used when queueing items.
author Zerotorescue
date Sat, 30 Oct 2010 23:04:45 +0200
parents 8f5c02113c5c
children 06fee4208bf2
line wrap: on
line source
do
	
	local function GetTotalCount(itemId)
		local realm = GetRealmName();
		
		local totalCount = 0;
		
		-- Process all accounts
		for accountName in pairs(DataStore:GetAccounts()) do
		
			-- Process all charracters
			for characterName, character in pairs(DataStore:GetCharacters(realm, accountName)) 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
		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 (without guilds)", GetTotalCount, GetCharacterCount, IsEnabled);
	
end