Quantcast
WoWInterface - View Single Post - code integration
View Single Post
09-25-17, 06:54 AM   #1
Uitat
A Flamescale Wyrmkin
 
Uitat's Avatar
AddOn Author - Click to view addons
Join Date: May 2011
Posts: 141
code integration

trying to work some code in, could i get a hand

trying to shorten the numbers in my artifact bar adding this code in but not sure how to name it all to my own code

here is my code

Lua Code:
  1. local AXP_COLOR = { r = 0.6, g = 0.2, b = 0.1 }
  2. --Lets set up the Frame
  3. local derArtifactBar = CreateFrame("Statusbar", "derArtifactBar",artifactFrame)
  4.     derArtifactBar:SetPoint("CENTER", 0, 0)
  5.     derArtifactBar:SetHeight(18)
  6.     derArtifactBar:SetWidth(artifactFrame:GetWidth() * .968)
  7.     derArtifactBar:SetStatusBarTexture("Interface\\AddOns\\_Deranjata\\media\\cast\\Waterline")
  8.     derArtifactBar:SetStatusBarColor(AXP_COLOR.r, AXP_COLOR.g, AXP_COLOR.b, 0.5)
  9.     derArtifactBar:SetBackdrop({
  10.     bgFile =  "Interface\\AddOns\\_Deranjata\\media\\cast\\Lines",
  11.     insets = { left = 1, right = 1, top = 1, bottom = 1 }
  12.     })
  13. derArtifactBar:SetBackdropColor(0.1, 0.1, 0.1)
  14. derArtifactBar:SetBackdropBorderColor(0.6, 0.6, 0.6)
  15. --lets clear any text then set out centerpoint
  16. derArtifactBar.Text=derArtifactBar:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  17. derArtifactBar.Text:SetPoint("CENTER")      
  18.  
  19. --Registering out watched events
  20. derArtifactBar:RegisterEvent("PLAYER_ENTERING_WORLD")
  21. derArtifactBar:RegisterEvent("ARTIFACT_XP_UPDATE")
  22. derArtifactBar:RegisterEvent("UNIT_INVENTORY_CHANGED")
  23.  
  24. -- now lets update the position and text on the bar so we can always have accurate info
  25. derArtifactBar:SetScript("OnEvent", function(self, event, ...)
  26.     if not HasArtifactEquipped() then self:Hide() return end
  27.     self:Show()
  28.     local itemID, altItemID, name, icon, xp, pointsSpent, quality, artifactAppearanceID, appearanceModID, itemAppearanceID, altItemAppearanceID, altOnTop, artifactTier = C_ArtifactUI.GetEquippedArtifactInfo()
  29.     local numPoints, artifactXP, xpForNextPoint = MainMenuBar_GetNumArtifactTraitsPurchasableFromXP(pointsSpent, xp, artifactTier)
  30.     self:SetMinMaxValues(0,xpForNextPoint)
  31.     self:SetValue(artifactXP)
  32.  
  33.    
  34.    local bugFix = artifactXP/xpForNextPoint
  35.     self.Text:SetFormattedText("Current %d +%d Points",bugFix,numPoints)
  36.  
  37.  
  38. -- self.Text:SetFormattedText("Artifact XP: %d / %d       +%d Points",artifactXP,xpForNextPoint,numPoints)
  39. end)

want to add this in to replace line

local bugFix = artifactXP/xpForNextPoint
self.Text:SetFormattedText("Current %d +%d Points",bugFix,numPoints)

Lua Code:
  1. local function ReadableNumber(num, places)
  2.     local ret
  3.     local placeValue = ("%%.%df"):format(places or 0)
  4.     if not num then
  5.         return 0
  6.     elseif num >= 1000000000000 then
  7.         ret = placeValue:format(num / 1000000000000) .. " Tril" -- trillion
  8.     elseif num >= 1000000000 then
  9.         ret = placeValue:format(num / 1000000000) .. " Bil" -- billion
  10.     elseif num >= 1000000 then
  11.         ret = placeValue:format(num / 1000000) .. " Mil" -- million
  12.     elseif num >= 1000 then
  13.         ret = placeValue:format(num / 1000) .. "k" -- thousand
  14.     else
  15.         ret = num -- hundreds
  16.     end
  17.     return ret
  18. end
then re-enable the commented out self.text at the bottom of my code
__________________
  Reply With Quote