WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Search/Requests (https://www.wowinterface.com/forums/forumdisplay.php?f=6)
-   -   target health percentage (https://www.wowinterface.com/forums/showthread.php?t=59313)

realitysucks 11-02-22 10:54 PM

target health percentage
 
i used to have an addon back in retail wrath and on private servers which showed status text in a neat way, i have the code here but it doesnt work with the classic client, does anyone know how to make it behave like intended?

i know theres an option to show percentage and status text in game but i dont like how its displayed

Code:

hooksecurefunc("TextStatusBar_UpdateTextString", function(textStatusBar)
        if textStatusBar == TargetFrameHealthBar and not GetCVarBool("statusTextPercentage") and not textStatusBar.showPercentage then
                local s = TargetFrameTextureFrameHealthBarText:GetText()
                if s then
                        s = string.match(s, "[^%/%(]+")
                        if s then
                                TargetFrameTextureFrameHealthBarText:SetText(s.."("..tostring(math.ceil((UnitHealth("target") / UnitHealthMax("target")) * 100)).."%)")
                        end
                end
        end
end)

this is how it looks like:

SDPhantom 11-03-22 01:31 PM

Lua Code:
  1. hooksecurefunc("TextStatusBar_UpdateTextStringWithValues",function(self,text,val,min,max)
  2.     if self==TargetFrameHealthBar and max>0 and (val>0 or not self.zeroText) then
  3.         if self.LeftText then self.LeftText:Hide(); end
  4.         if self.RightText then self.RightText:Hide(); end
  5.  
  6.         text:SetFormattedText("%s (%d%%)",AbbreviateLargeNumbers(val),math.ceil(100*val/max));
  7.         text:Show();
  8.     end
  9. end);

realitysucks 11-04-22 01:01 AM

works like a charm! tyvm :)


All times are GMT -6. The time now is 03:07 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI