LibStub library to cache artifact trait information. Updates is handled by the library and data can safely be accessed after the PLAYER_ENETERING_WORLD event occurs.
Usage:
local LA = LibStub:GetLibrary("LegionArtifacts-1.1")
Public functions:
GetArtifacts() - returns a table array listing of obtained artifact weapons (includes bags, but not banks)
GetPowerPurchased(artifactID) - returns number of powers purchased for specified ID (or equipped if not specified)
GetPowers(artifactID) - returns a table array list of artifact powers, defaults to equipped artifact if no artifactID.
GetPowerInfo(powerID,artifactID) - returns an information array about the specified powerID, defaults to equipped artifact if no artifactID.
All public functions will return false on errors or empty data.
Code:
--for all artifacts and artifact powers, print the power ranks.
for i,artifact in pairs(LA:GetArtifacts()) do
local _,link = GetItemInfo(artifact)
local numRank = LA:GetPowerPurchased(artifact)
print(link, 'Powers purchased: ' .. numRank)
for j,power in pairs(LA:GetPowers(artifact)) do
local x = LA:GetPowerInfo(power,artifact)
local id,_,curRank = unpack(x)
print(GetSpellLink(id),'Rank: ' .. curRank)
end
end
Credits: Rainrider's macro code as a starting base.