Unitframes better health abbreviation?

From what I can tell, in the “older days” there were addons (Such as UnitFramesImproved) that used the following to be able to set custom health text on unit frames:

hooksecurefunc(“TextStatusBar_UpdateTextStringWithValues”, FunctionToCall);

But ever since the latest Dragonflight patch (10.2.7), that method can no longer be hooked into.
So now when a target has for example 1.500.000 health, it is written out as “1500k” instead of “1.5m”.

Is there a new function to hook into instead? Is there another way to customize how the health numbers are abbreviated?

https://github.com/Gethe/wow-ui-source/blob/live/Interface/AddOns/Blizzard_TextStatusBar/Mainline/TextStatusBar.lua#L78

hooksecurefunc("TextStatusBarMixin","UpdateTextStringWithValues", FunctionToCall);

Ah, I see! Thanks, this repo is definitely useful for future references.
I tried fiddling some more with it. It seems if I used a string for the Table reference, it threw exceptions.
So this line made it not-break on load:

hooksecurefunc(TextStatusBarMixin,"UpdateTextStringWithValues", FunctionToCall);

If I changed the 2nd parameter, it would complain about the function not existing. So that part is at least correct.
But the actual callback I referenced (FunctionToCall). No matter how many parameters I give it, that is never called.

You may need to wait till the Mixin has loaded before you hook into it. Not sure, I’m better with macros than Lua.

[added]
Hmm ElvUI seems to prefix all their Mixin hooks with _G.

So like,

local _G = _G
hooksecurefunc(_G.TextStatusBarMixin,"UpdateTextStringWithValues", FunctionToCall);

Thanks! I tried both this (And a bunch of other things I could google my way to). None of it ever seems to register events on this mixin.

I just have to keep trying until something works haha

I actually just found another forum post that gave a perfect solution: https://us.forums.blizzard.com/en/wow/t/player-target-health-text/1848056/2

1 Like

Nice, Fizzle does good work.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.