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:
local f = CreateFrame("Frame")
f:RegisterEvent("ADDON_LOADED")
f:SetScript("OnEvent", function(self, event, ...)
local addonName = ...
if addonName == "Blizzard_AchievementUI" then
self:UnregisterAllEvents()
EXPORTSTATSDB = EXPORTSTATSDB or {} -- create SV table iuf required
local player = UnitName("player") -- create sub-table for current polayer info
player = player.."-"..GetRealmName()
EXPORTSTATSDB[player] = EXPORTSTATSDB[player] or {}
local SVKey = EXPORTSTATSDB[player]
local categories = STAT_FUNCTIONS.categoryAccessor()
wipe(SVKey) -- clear the tasble tyo update with latest ionformation
for catid, cat in ipairs(categories) do
local catName = GetCategoryInfo(cat)
local total, completed, incompleted = GetCategoryNumAchievements(cat)
SVKey[catName] = {} -- create category sub-sub table
SVKey[catName].total = total
SVKey[catName].completed =completed
SVKey[catName].incompleted = incompleted
SVKey[catName].Stats = {} -- create sub-sub-sub table for category stats
local Stats = SVKey[catName].Stats
for i=1, total do
local quantity, skip, cid = GetStatistic(cat, i)
if not skip then
local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuild, wasEarnedByMe, earnedBy, isStatistic = GetAchievementInfo(cat, i)
Stats[id] = {}
local Stat = Stats[id]
Stat.name = name
Stat.points = points
Stat.completed = completed
Stat.month = month
Stat.day = day
Stat.year = year
Stat.description = description
Stat.flags = flags
Stat.icon = icon
Stat.rewardText = rewardText
Stat.isGuild = isGuild
Stat.wasEarnedByMe = wasEarnedByMe
Stat.earnedBy = earnedBy
Stat.quantity = quantity
Stat.isStatistic = isStatistic
local numCriteria = GetAchievementNumCriteria(id)
if numCriteria > 0 then
Stat.criteria = {}
Stat.numCriteria = numCriteria
for c = 1, numCriteria do
local criteriaString, criteriaType, completed, quantityNumber, reqQuantity, charName, flags, assetID, quantity = GetAchievementCriteriaInfo(id, c)
tinsert(Stat.criteria, {
criteriaString=criteriaString,
criteriaType=criteriaType,
completed=completed,
quantityNumber=quantityNumber,
reqQuantity=reqQuantity,
charName=charName,
flags=flags,
assetID=assetID,
quantity=quantity,
})
end
end
end
end
end
end
end)