How to add thousands separator for existing addon?
There is an addon "sidWarTools" which doesnīt have thousands separator on target label text. It is hard to read bigger numbers. How to add thousands separator for this addon?
there is a line in "target.lua": local targetBarText = CreateControlFromVirtual(parent:GetName().."HpText1", parent, "ZO_UnitFrameBarText") targetBarText:SetAnchor(TOP, nil, BOTTOM, 0, -22) targetBarText:SetFont("ZoFontWinT2") targetHealthBar.leftText = targetBarText I īve tried to add this lines, but it doesnīt work.: strformat('%s / %s (%d%%)', comma_value(current), comma_value(effMax), (current / effMax) * 100) How to resolve this pls? |
Wait an update from the author, he knows the answer.
|
Iīve already asked. I know, the answer can be very late, thatīs why Iīm asking here too.
|
ZO_CommaDelimitNumber(number)
|
Where to put it pls?
|
I've never used it so I don't know anything about what it is displaying, but
targetHealthBar.leftText = targetBarText writes the text to the bar. So what does targetBarText contain? If it's purely the number, then you can do: targetHealthBar.leftText = ZO_CommaDelimitNumber(targetBarText) If it isn't just the number, then you need to go back to the point where that is first created and ensure the number added to that text is formatted first. |
Adding this resolved to this lua error:
EsoUI/Libraries/Globals/Localization.lua:112: operator < is not supported for userdata < number stack traceback: EsoUI/Libraries/Globals/Localization.lua:112: in function 'ZO_CommaDelimitNumber' user:/AddOns/sidWarTools/misc/AttributeBars.lua:209: in function 'InitializeTargetFrameHealthBar' user:/AddOns/sidWarTools/misc/AttributeBars.lua:565: in function 'Initialize' user:/AddOns/sidWarTools/StartUp.lua:59: in function 'callback' user:/AddOns/sidWarTools/StartUp.lua:39: in function '(anonymous)' EDIT: and thatīs the whole text in this target lua: local function InitializeTargetFrameHealthBar(saveData, dividerPool) local activeDividers = {} local HIDE_BAR_TEXT, SHOW_BAR_TEXT = 0, 2 -- keep synced with constants in unitframes.lua local targetFrame = ZO_UnitFrames_GetUnitFrame(TARGET_UNIT_TAG) local targetHealthBar = targetFrame.healthBar local parent = targetFrame.frame local barLeft = targetHealthBar.barControls[1] local barRight = targetHealthBar.barControls[2] local targetBarText = CreateControlFromVirtual(parent:GetName().."HpText1", parent, "ZO_UnitFrameBarText") targetBarText:SetAnchor(TOP, nil, BOTTOM, 0, -22) targetBarText:SetFont("ZoFontWinT2") targetHealthBar.leftText = ZO_CommaDelimitNumber(targetBarText) targetHealthBar.UpdateText = function(self) if(self.showBarText == SHOW_BAR_TEXT) then local shieldValue = GetUnitAttributeVisualizerEffectInfo(TARGET_UNIT_TAG, ATTRIBUTE_VISUAL_POWER_SHIELDING, STAT_MITIGATION, ATTRIBUTE_HEALTH, POWERTYPE_HEALTH) local text = GetBarText(self.currentValue, shieldValue, self.maxValue, self.useDividerTextMode and saveData.dividerTextMode or saveData.generalTextMode) self.leftText:SetText(text) self.leftText:SetHidden(false) else self.leftText:SetHidden(true) end end |
The first part looks like it was the wrong part of the code then.
Code:
local text = GetBarText(self.currentValue, shieldValue, self.maxValue, self.useDividerTextMode and saveData.dividerTextMode or saveData.generalTextMode) I believe GetBarText() is a custom function. If it is, you'll have to find it and it'd likely be the place to modify the number display, unless the following works: Code:
local text = GetBarText(ZO_CommaDelimitNumber(self.currentValue), ZO_CommaDelimitNumber(shieldValue), ZO_CommaDelimitNumber(self.maxValue), self.useDividerTextMode and saveData.dividerTextMode or saveData.generalTextMode) |
It seems it doesnīt work. Itś a pitty, because itīs hard to read for example this number on HP:
12256682 |
Then you'll have to find GetBarText() and change it there, rather than the input to it.
|
Found it:
WrapFunction(attributeBar.label, "SetText", function(originalSetText, self) local shieldValue if(hasShield) then shieldValue = GetUnitAttributeVisualizerEffectInfo(PLAYER_UNIT_TAG, ATTRIBUTE_VISUAL_POWER_SHIELDING, STAT_MITIGATION, ATTRIBUTE_HEALTH, POWERTYPE_HEALTH) end local text = GetBarText(attributeBar.current, shieldValue, attributeBar.max, attributeBar.useDividerTextMode and saveData.dividerTextMode or saveData.generalTextMode) originalSetText(self, text) end) |
Iīve also discovered this one:
local function GetBarText(current, shieldValue, max, format) if(format == TEXT_MODE_PERCENT) then return GetPercentText(current, max) elseif(format == TEXT_MODE_ABSOLUTE) then return zo_strformat("<<1>> / <<2>>", current, max) elseif(format == TEXT_MODE_BOTH) then if(shieldValue and shieldValue > 0) then return zo_strformat("<<1>> + <<2>> / <<3>> (<<4>> + <<5>>)", current, shieldValue, max, GetPercentText(current, max), GetPercentText(shieldValue, max)) else return zo_strformat("<<1>> / <<2>> (<<3>>)", current, max, GetPercentText(current, max)) end end end |
Hi there,
The part you should edit is the GetBarText function in line 147 of misc/AttributeBars.lua. That's where the text is generated based on your addon settings. In case you use the mode where only absolute numbers are shown you would want to change line 151 to Lua Code:
For the next release, I can add additional options for how the numbers are formatted. I am thinking about adding the choices "raw" (like it has been until now), "comma separated" and "shortened" (e.g. 100k). Let me know what you think. |
OK. Iīve tried it. No luck. Iīll wait then for your update.
Wish you good evening |
All times are GMT -6. The time now is 11:26 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI