View Single Post
11-15-16, 01:40 PM   #22
_Max_Cavalera_
A Fallenroot Satyr
 
_Max_Cavalera_'s Avatar
Join Date: Dec 2007
Posts: 28
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:
  1. local akMulti = {
  2.     0,
  3.     25, 50, 90, 140, 200,
  4.     275, 375, 500, 650, 850,
  5.     1100, 1400, 1775, 2250, 2850,
  6.     3600, 4550, 5700, 7200, 9000,
  7.     11300, 14200, 17800, 22300, 24900
  8. };
  9.  
  10. local frame = CreateFrame("Frame", "m4xArtifactFrame", UIParent);
  11. local text = frame:CreateFontString(nil, "ARTWORK");
  12. text:SetFont("Fonts\\FRIZQT__.TTF", 15, "OUTLINE");
  13. text:SetJustifyH("LEFT");
  14. text:SetTextColor(1, 0.82, 0);
  15. text:SetPoint("TOPLEFT", UIParent, "TOPLEFT");
  16.  
  17. text:SetText("Initializing...");
  18.  
  19. frame:SetAllPoints(text);
  20.  
  21. frame:RegisterEvent("PLAYER_ENTERING_WORLD");
  22. frame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED");
  23. frame:RegisterEvent("ARTIFACT_CLOSE");
  24. frame:RegisterEvent("ARTIFACT_RESPEC_PROMPT");
  25. frame:RegisterEvent("ARTIFACT_XP_UPDATE");
  26.  
  27. frame:SetScript("OnEvent", function(self, event, ...)
  28.     local itemID, _, itemName, itemIcon, totalXP, pointsSpent = C_ArtifactUI.GetEquippedArtifactInfo()
  29.    
  30.     if itemID then
  31.         local pointsFree, xpToNextPoint = 0, C_ArtifactUI.GetCostForPointAtRank(pointsSpent);
  32.         local _, akLevel = GetCurrencyInfo(1171);
  33.        
  34.         while totalXP >= xpToNextPoint do
  35.             totalXP, pointsSpent, pointsFree, xpToNextPoint = totalXP - xpToNextPoint, pointsSpent + 1, pointsFree + 1, C_ArtifactUI.GetCostForPointAtRank(pointsSpent + 1);
  36.         end
  37.         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]);
  38.     end
  39.  
  40.     frame:SetShown(itemID and true or false);
  41. 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?

Last edited by _Max_Cavalera_ : 11-15-16 at 01:50 PM.
  Reply With Quote