Quantcast
General Subcategory Missing when parsing Achievements - ESOUI
Thread Tools Display Modes
01/04/21, 07:32 PM   #1
QuantumPie
AddOn Author - Click to view addons
Join Date: Sep 2019
Posts: 29
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.

Last edited by QuantumPie : 01/04/21 at 08:46 PM.
  Reply With Quote
01/05/21, 12:00 AM   #2
ZOS_DanBatson
ZOS Staff!
 
ZOS_DanBatson's Avatar
Yes this person is from ZeniMax!
Join Date: Jul 2015
Posts: 78
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."
  Reply With Quote
01/05/21, 05:45 AM   #3
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 540
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
__________________
@votan73 (EU - megaserver)
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » General Subcategory Missing when parsing Achievements

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off