ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   General Subcategory Missing when parsing Achievements (https://www.esoui.com/forums/showthread.php?t=9537)

QuantumPie 01/04/21 07:32 PM

General Subcategory Missing when parsing Achievements
 
I'm using the following code to parse through all the achievements in the game:
Lua Code:
  1. for topLevelIndex = 1, GetNumAchievementCategories() do
  2.             local categoryName, numSubCatgories, _  = GetAchievementCategoryInfo(topLevelIndex)
  3.             d(categoryName)
  4.             if self.svAccount.achievements[categoryName] == nil then self.svAccount.achievements[categoryName] = {totalPoints = 0, categoryIndex = topLevelIndex, subCategories = {}} end
  5.             for subCategoryIndex = 1, numSubCatgories do
  6.                 local subCategoryName, numSubAchievements = GetAchievementSubCategoryInfo(topLevelIndex, subCategoryIndex)
  7.                 if self.svAccount.achievements[categoryName]["subCategories"][subCategoryName] == nil then self.svAccount.achievements[categoryName]["subCategories"][subCategoryName] = {} end
  8.                 for index = 1, numSubAchievements do
  9.                     local id = GetAchievementId(topLevelIndex, subCategoryIndex, index)
  10.                     local name, _, points, _, completed, date, _ = GetAchievementInfo(id)
  11.                     if self.svAccount.achievements[categoryName]["subCategories"][subCategoryName][name] == nil then self.svAccount.achievements[categoryName]["subCategories"][subCategoryName][name] = {id = id, characters = {}} end
  12.                     if completed then
  13.                         local characterArray = self.svAccount.achievements[categoryName]["subCategories"][subCategoryName][name]["characters"]
  14.                         characterArray[#characterArray + 1] = {name = playerName, date = date}
  15.                     end
  16.  
  17.                 end
  18.             end
  19.         end

When I use Zgoo to inspect the saved variables, I noticed that the general sub category was only recorded for the category of Harrowstorm and Stonethorns (the two most recent dungeon DLCs). It was missing from every other category. If this is the intended behavior, how do I capture the general subcategories? I don't see any other functions from the API page on the wiki which could give that info.

ZOS_DanBatson 01/05/21 12:00 AM

The vanilla UI will add a fake "General" subcategory to a parent category if there are other subcategories and also achievements in the parent category. The "General" categories you found via the API were probably hand created by designers as real subcategories called "General."

votan 01/05/21 05:45 AM

The "general" sub-category is the value nil.

Lua Code:
  1. function addon:InitialAchievements()
  2.     local function GetAchievements(topLevelIndex, categoryIndex, numAchievements)
  3.         for achievementIndex = 1, numAchievements do
  4.             local achievementId = GetAchievementId(topLevelIndex, categoryIndex, achievementIndex)
  5. -- ...
  6.         end
  7.     end
  8.  
  9.     local numCategories = GetNumAchievementCategories()
  10.     for topLevelIndex = 1, numCategories do
  11.         local _, numSubCatgories, numAchievements = GetAchievementCategoryInfo(topLevelIndex)
  12.         -- General
  13.         GetAchievements(topLevelIndex, nil, numAchievements)
  14.         for subCategoryIndex = 1, numSubCatgories do
  15.             local _, numAchievements = GetAchievementSubCategoryInfo(topLevelIndex, subCategoryIndex)
  16.             GetAchievements(topLevelIndex, subCategoryIndex, numAchievements)
  17.         end
  18.     end
  19. end


All times are GMT -6. The time now is 05:24 AM.

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