View Single Post
04-17-24, 09:23 AM   #16
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,950
Okay, so what I gave you will do what you want. All you need to do is utilise what I did for 1 achievement to make it work for multiple achievements.

For example:

Initialisation Stage
You could use that for loop to add to a list of achievement id, criteria id items.

Processing Stage
You could then go through the generated list of achievement/criteria ids and do what you want with them.

Here's what might work to get the first part of it working.

Lua Code:
  1. local addonName, addon = ...
  2.  
  3. -- Make sure achievements to track table exists
  4. local achievementsToMonitor = {
  5.     [6351] = {},
  6.     [6975] = {},
  7.     [6977] = {},
  8.     -- And any others you want to grab the information for
  9. }
  10.  
  11. -- Create variables for the values you are using in the loops
  12. local numCriteria, criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString, criteriaID, eligible
  13.  
  14.  
  15. local function InitialiseMonitorTable()
  16.  
  17.     -- Go through each achievement in the monitor list
  18.     for achievementID,data in pairs(achievementsToMonitor) do
  19.  
  20.         numCriteria = GetAchievementNumCriteria(achievementID)
  21.  
  22.         -- Go through each criteria for this achievement
  23.         for criteriaIndex = 1,numCriteria do
  24.  
  25.             -- Grab the data for this criteriaIndex
  26.  
  27.             criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString, criteriaID, eligible
  28.            = GetAchievementCriteriaInfo(achievementID, criteriaIndex)
  29.  
  30.            -- This is where you might want to decide what to do with the information while it is available.
  31.  
  32.             data.criteriaID = criteriaID
  33.             data.criteriaString = criteriaString
  34.             data.criteriaType = criteriaType
  35.             data.completed = completed
  36.             data.assetID = assetID
  37.             -- Any others you might want to store in the table
  38.  
  39.             -- I am not 100% sure that this keeps the data in the table once you store it here
  40.             -- But if not replace the data part with the following and see if that works
  41.             -- achievementsToMonitor[achievementID]
  42.  
  43.         end
  44.     end
  45. end
  46.  
  47.  
  48. local function ProcessMonitorTable()
  49. -- Do whatever code you want to do in here and call it when you want it to be called
  50. end
  51.  
  52.  
  53. -- The usual EventWatcher code block
  54. local eventWatcher = CreateFrame("Frame")
  55.  
  56. local function OnEvent(self,event,...)
  57.    
  58.     if event == "ADDON_LOADED" then
  59.         local addonLoaded = ...
  60.         local okayToContinue = okayToContinue or false
  61.         if addonLoaded == addonName then
  62.        
  63.             -- If you forget to add the Achievement Addon in the required dependancies part
  64.             -- of the TOC do this to ensure the addon is loaded before you do any work
  65.             local isAchievementsLoaded = C_AddOns.IsAddOnLoaded("Blizzard_AchievementUI")
  66.             if isAchievementsLoaded then
  67.                 okayToContinue = true
  68.             else
  69.                 okayToContinue = false
  70.                 LoadAddOn("Blizzard_AchievementUI")
  71.             end
  72.         elseif addonLoaded == "Blizzard_AchievementUI" then
  73.            
  74.             -- Make sure our addon is loaded ( hopefully by now it is )
  75.             local isMyAddonLoaded = C_AddOns.IsAddOnLoaded(addonName)
  76.            
  77.             if isMyAddonLoaded then
  78.                 okayToContinue = true
  79.             end
  80.        
  81.         end
  82.        
  83.         -- The two above checks should make sure that both addons are available before
  84.         -- setting the okayToContinue variable to true.
  85.         if okayToContinue then
  86.             InitialiseMonitorTable()
  87.         end
  88.        
  89.     end    
  90.    
  91. end
  92. eventWatcher:SetScript( "OnEvent", OnEvent );
  93. eventWatcher:RegisterEvent( "ADDON_LOADED" );
  94. -- Add whatever other events you might be needing to be watched for the rest of the addons workload
  95. -- And the appropriate section in the OnEvent function


I added the assetID into the mix as you may find this useful
At the bottom of the wiki.gg page for the criteriainfo function it shows a table highlight what the assetID will be based on the type.

https://warcraft.wiki.gg/wiki/API_Ge...ntCriteriaInfo

For example:

A criteriaType of 0 will mean that this is a monster kill and the assetID will be the monsterID. The monsterID may be it's current GUID ( the GUID gets reset periodically for some things so it may be different week to week or month to month ).

A criteriaType of 43 denotes an exploration criteria and the assetID might be an ID that represents the location. Maybe a mapID, zoneID or subZone etc They don't seem to be 100% sure of this so you might find it out through testing.

Hopefully that will help you with that first part of your addon.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote