View Single Post
02-04-22, 09:21 PM   #11
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,897
The first one using Saved Variables (assuming EXPORTSTATSDB as the SV declared in the .toc) might look something like (saves the data under each character name/realm sub key) (it's just a crude example so treat accoringly):

You have to open the achievements frame for it to work.

Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("ADDON_LOADED")
  3. f:SetScript("OnEvent", function(self, event, ...)
  4.     local addonName = ...
  5.     if addonName == "Blizzard_AchievementUI" then
  6.         self:UnregisterAllEvents()
  7.         EXPORTSTATSDB  = EXPORTSTATSDB or {} -- create SV table iuf required
  8.         local player = UnitName("player") -- create sub-table for current polayer info
  9.         player = player.."-"..GetRealmName()
  10.         EXPORTSTATSDB[player] = EXPORTSTATSDB[player] or {}
  11.         local SVKey = EXPORTSTATSDB[player]
  12.         local categories = STAT_FUNCTIONS.categoryAccessor()
  13.         wipe(SVKey) -- clear the tasble tyo update with latest ionformation
  14.         for catid, cat in ipairs(categories) do
  15.             local catName = GetCategoryInfo(cat)
  16.             local total, completed, incompleted = GetCategoryNumAchievements(cat)
  17.             SVKey[catName] = {} -- create category sub-sub table
  18.             SVKey[catName].total = total
  19.             SVKey[catName].completed =completed
  20.             SVKey[catName].incompleted = incompleted
  21.             SVKey[catName].Stats = {} -- create sub-sub-sub table for category stats
  22.             local Stats = SVKey[catName].Stats
  23.             for i=1, total do
  24.                 local quantity, skip, cid = GetStatistic(cat, i)
  25.                 if not skip then
  26.                     local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuild, wasEarnedByMe, earnedBy, isStatistic = GetAchievementInfo(cat, i)
  27.                     Stats[id] = {}
  28.                     local Stat = Stats[id]
  29.                     Stat.name = name
  30.                     Stat.points = points
  31.                     Stat.completed = completed
  32.                     Stat.month = month
  33.                     Stat.day = day
  34.                     Stat.year = year
  35.                     Stat.description = description
  36.                     Stat.flags = flags
  37.                     Stat.icon = icon
  38.                     Stat.rewardText = rewardText
  39.                     Stat.isGuild = isGuild
  40.                     Stat.wasEarnedByMe = wasEarnedByMe
  41.                     Stat.earnedBy = earnedBy
  42.                     Stat.quantity = quantity
  43.                     Stat.isStatistic = isStatistic
  44.                     local numCriteria = GetAchievementNumCriteria(id)
  45.                     if numCriteria > 0 then
  46.                         Stat.criteria = {}
  47.                         Stat.numCriteria = numCriteria
  48.                         for c = 1, numCriteria do
  49.                             local criteriaString, criteriaType, completed, quantityNumber, reqQuantity, charName, flags, assetID, quantity = GetAchievementCriteriaInfo(id, c)
  50.                             tinsert(Stat.criteria, {
  51.                                 criteriaString=criteriaString,
  52.                                 criteriaType=criteriaType,
  53.                                 completed=completed,
  54.                                 quantityNumber=quantityNumber,
  55.                                 reqQuantity=reqQuantity,
  56.                                 charName=charName,
  57.                                 flags=flags,
  58.                                 assetID=assetID,
  59.                                 quantity=quantity,
  60.                             })
  61.                         end
  62.                     end
  63.                 end
  64.             end
  65.         end
  66.     end
  67. end)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 02-05-22 at 09:40 AM.
  Reply With Quote