WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Access Player Statistics (https://www.wowinterface.com/forums/showthread.php?t=59561)

Walkerbo 04-23-23 06:31 PM

Access Player Statistics
 
I am trying to access the players statistics data as shown in the achievement frame statistics tab.

I assume there is a table of statistics yet I have not been able to find it.

I have looked in the StatsFrame.xml and StatsFrame.lua files but can see nothing that defines the statistics table.

How do I find the appropriate statistics table?

Fizzlemizz 04-23-23 09:48 PM

Are you meaning, how to get achievement information?
and GetAchievementCriteriaInfo

In Blizzard_AchievementUI.lua probably start at:
Code:

function AchievementStatTemplateMixin:Init(elementData)
You'll see where it's setting header text (if elementData.header) else the stat name text and quantity.

Walkerbo 04-24-23 05:55 PM

Heya Fizzlemizz

I don't need the achievements, I want the player stats, such as how many deaths, items consumed, flight paths taken, etc.

These stats are displayed in the Statistic Tab in the achievement UI.

SDPhantom 04-24-23 07:33 PM

Might want to check out GetStatistic(). GetStatisticsCategoryList() appears to return a list of statistic CategoryIDs that can be enumerated through with the generic achievement functions to find the AchievementID you want.

For example:
Lua Code:
  1. for _,catid in ipairs(GetStatisticsCategoryList()) do
  2.     for i=1,GetCategoryNumAchievements(catid,true) do
  3.         local achid,achname=GetAchievementInfo(catid,i);
  4.         print(("(%d) %s: %d"):format(achid,achname,GetStatistic(achid)));
  5.     end
  6. end

This prints the entire list of statistics, their related AchievementID for later tracking, and the current statistic value. It takes a few seconds to complete.

Fizzlemizz 04-24-23 08:11 PM

The AchievementStatTemplateMixin:Init function is called to fill each row of the stats list.

The GetAchievementInfo function returns information including the stat name, then either GetStatistic or GetAchievementCriteriaInfo depending.

Walkerbo 04-25-23 12:49 AM

Hi Fizzlemizz and SDPhantom

Thanks for your help, your answers make sense and the code provided absolutely works.

Cheers


All times are GMT -6. The time now is 02:55 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI