Thank you for the small demo.
I have to ask, could you held me to integrade your demo into my litte addon? I am new in Lua programming. everytime a have time I read tutorial and try to learn but time for that is rare.
In the ArtifactFrame I would see how many Artifactpower was assigned to my weapon, because i like statistics
I would animate the assigned artifactpower text when new power was added and the frame was visible. Like the default available artifactpower text.
Lua Code:
AssignedArtifactPower = LibStub("AceAddon-3.0"):NewAddon("Assigned Artifact Power", "AceEvent-3.0")
--Make a 'Comma/Point' Value
function AssignedArtifactPower:comma_value(n)
local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
return left..(num:reverse():gsub('(%d%d%d)','%1.'):reverse())..right
end
function AssignedArtifactPower:calc_ap()
local c, ge, gc, xp, ps, n, _ = _G.C_ArtifactUI
_, _, n, _, xp, ps = c.GetEquippedArtifactInfo()
for i=1,ps-1 do
xp = xp + c.GetCostForPointAtRank(i)
end
AP = self:comma_value(xp)
end
function AssignedArtifactPower:OnEnable()
self:RegisterEvent("ARTIFACT_UPDATE")
self:RegisterEvent("ARTIFACT_XP_UPDATE")
self:RegisterEvent("ARTIFACT_MAX_RANKS_UPDATE")
self:Refresh()
end
function AssignedArtifactPower:ARTIFACT_UPDATE()
self:Refresh()
end
function AssignedArtifactPower:ARTIFACT_XP_UPDATE()
self:Refresh()
end
function AssignedArtifactPower:ARTIFACT_MAX_RANKS_UPDATE()
self:Refresh()
end
function AssignedArtifactPower:Overlay()
AFP = ArtifactFrame.PerksTab
if not AFP.AssignedArtifactPower then
AF = AFP.TitleContainer
AFPoints = AF.PointsRemainingLabel
AFLabel = AF.ArtifactPower
--New Frame for available Artifactpower
AFP.ArtifactPower = CreateFrame("Frame", "ArtifactPower", AFP)
AFP.ArtifactPower:SetPoint("TOP", -75, -120, "CENTER")
AFP.ArtifactPower:SetWidth(150)
AFP.ArtifactPower:SetHeight(40)
AFLabel:ClearAllPoints()
AFLabel:SetPoint("TOP", AFP.ArtifactPower, 0, 0, "CENTER")
AFPoints:ClearAllPoints()
AFPoints:SetPoint("BOTTOM", AFLabel, 0, -15, "CENTER")
--New Frame for assigned Artifactpower
AFP.AssignedArtifactPower = CreateFrame("Frame", "AssignedArtifactPower", AFP)
AFP.AssignedArtifactPower:SetPoint("TOP", 75, -120, "CENTER")
AFP.AssignedArtifactPower:SetWidth(150)
AFP.AssignedArtifactPower:SetHeight(40)
tAPL = AFP.AssignedArtifactPower:CreateFontString("ArtifactPowerLabel", "ARTWORK")
tAPL:SetFont(AFLabel:GetFont())
tAPL:SetPoint("TOP", AFP.AssignedArtifactPower, 0, 0, "CENTER")
tAPL:SetTextColor(AFLabel:GetTextColor())
tAPL:SetText("Assigned")
tAP = AFP.AssignedArtifactPower:CreateFontString("ArtifactPowerPoints", "ARTWORK")
tAP:SetFont(AFPoints:GetFont())
tAP:SetPoint("BOTTOM", tAPL, 0, -15, "CENTER")
tAP:SetTextColor(AFPoints:GetTextColor())
self:calc_ap()
tAP:SetText(AP)
AFP.AssignedArtifactPower:SetScript("OnEnter", function(self, motion)
GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
GameTooltip:ClearLines()
GameTooltip:SetText("Total assigned artifact power")
GameTooltip:AddLine("Resetting your weapons artifact power will reset this counter!", 1, 1, 1)
GameTooltip:Show()
end)
AFP.AssignedArtifactPower:SetScript("OnLeave", function(self, motion)
GameTooltip:Hide()
end)
else
self:calc_ap()
tAP:SetText(AP)
end
end
function AssignedArtifactPower:Refresh()
if not ArtifactFrame or not ArtifactFrame.PerksTab then return end
self:Overlay()
end
Of course my code is a bit dirty but it works