I still find it very strange like that. I get it, but just find it strange.
Definitely find the
not not itemid (that was talked about a few posts before) easier to understand in that case for some reason.
Thank you for the explanation and the link
ok, I implemented the code after doing minor changes that were needed for my personal taste.
Lua Code:
local akMulti = {
0,
25, 50, 90, 140, 200,
275, 375, 500, 650, 850,
1100, 1400, 1775, 2250, 2850,
3600, 4550, 5700, 7200, 9000,
11300, 14200, 17800, 22300, 24900
};
local frame = CreateFrame("Frame", "m4xArtifactFrame", UIParent);
local text = frame:CreateFontString(nil, "ARTWORK");
text:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE");
text:SetJustifyH("LEFT");
text:SetTextColor(1, 0.82, 0);
text:SetPoint("TOPLEFT", UIParent, "TOPLEFT");
text:SetText("Initializing...");
frame:SetAllPoints(text);
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
frame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED");
frame:RegisterEvent("ARTIFACT_CLOSE");
frame:RegisterEvent("ARTIFACT_RESPEC_PROMPT");
frame:RegisterEvent("ARTIFACT_XP_UPDATE");
frame:SetScript("OnEvent", function(self, event, ...)
local itemID, _, itemName, itemIcon, totalXP, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
if itemID then
local pointsFree, xpToNextPoint = 0, C_ArtifactUI.GetCostForPointAtRank(pointsSpent);
local _, akLevel = GetCurrencyInfo(1171);
while totalXP >= xpToNextPoint do
totalXP, pointsSpent, pointsFree, xpToNextPoint = totalXP - xpToNextPoint, pointsSpent + 1, pointsFree + 1, C_ArtifactUI.GetCostForPointAtRank(pointsSpent + 1);
end
text:SetFormattedText("AP |cff00ff00%d/%d (%.1f%%)|r" .. (pointsFree > 0 and " (+%d)" or "") .. "\nAK |cff00ff00%5$d (+%6$d%%)|r", totalXP, xpToNextPoint, 100 * totalXP / xpToNextPoint, pointsFree, akLevel, akMulti[akLevel + 1]);
end
frame:SetShown(itemID and true or false);
end);
Changes were:
- Obviously the variable names, I kinda have my own preference in naming scheme but that's irrelevant
- The font was changed because I looked at all the game font options from the XML files and none were exactly what I needed, unfortunately...
- Added 0 to the multiplier table to temporarily fix a problem I was getting where I was getting a nil value from multiplier[level] when the knowledge level was 0, and I'm going to talk about this after
- Because of adding the 0 to the table I had to add +1 to the level in multiplier[level] obviously
- Have some variables there not being used but i'm going to use them after
So, that nil because of the knowledge level 0. I totally get it why that is happening, it was trying to get multiplier[0] which doesn't exist since it starts at 1... BUT... on my original code I was doing the same mistake by accident, and it never gave me an error, not only that but it was actually working correctly, giving me on the output
knowledge level 0 (+0%)... that's kinda strange, no?