Thread Tools Display Modes
11-02-22, 10:54 PM   #1
realitysucks
A Defias Bandit
Join Date: Nov 2022
Posts: 2
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:
  Reply With Quote
11-03-22, 01:31 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
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);
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
11-04-22, 01:01 AM   #3
realitysucks
A Defias Bandit
Join Date: Nov 2022
Posts: 2
works like a charm! tyvm
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » target health percentage

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off