events of interest are UNIT_INVENTORY_CHANGED and AZERITE_EMPOWERED_ITEM_SELECTION_UPDATED
Event independent code:
local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem()
if (not azeriteItemLocation) then return end
local azeritePowerLevel = C_AzeriteItem.GetPowerLevel(azeriteItemLocation)
local specID = GetSpecializationInfo(GetSpecialization())
for slot = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED - 1 do -- exclude tabard
local item = Item:CreateFromEquipmentSlot(slot)
if (not item:IsItemEmpty()) then
local itemLocation = item:GetItemLocation()
if (C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItem(itemLocation)) then
local tierInfo = C_AzeriteEmpoweredItem.GetAllTierInfo(itemLocation)
for tier, info in next, tierInfo do
if (info.unlockLevel <= azeritePowerLevel) then
for _, powerID in next, info.azeritePowerIDs do
local powerInfo = C_AzeriteEmpoweredItem.GetPowerInfo(itemLocation, powerID)
if (powerInfo.selected and C_AzeriteEmpoweredItem.IsPowerAvailableForSpec(powerID, specID)) then
print('Azerite power:', powerID, powerInfo.spellID)
end
end
end
end
end
end
end
Azerite traits
Event independent code: