API GetStatistic

From Wowpedia
Jump to: navigation, search

Return the value of the requested Statistic.

value = GetStatistic(achievementID)

Arguments

(achievementID)
achievementID 
Integer - The ID of the Achievement


Returns

value 
String - The value of the requested Statistic.

Details

Using the achievementID's of actual Achievements, as opposed to statistics, generates strange results. More testing is needed.

Example

Here is a function that will take any statistic title (like Battlegrounds played) and will return the statistic ID for that statistic, so it can be used in other functions.

function GetStatisticId(StatisticTitle)
	for _, CategoryId in pairs(GetStatisticsCategoryList()) do	
		for i = 1, GetCategoryNumAchievements(CategoryId) do
			local IDNumber, Name = GetAchievementInfo(CategoryId, i)
			if Name == StatisticTitle then
				return IDNumber
			end
		end		
	end
	return -1
end