Topic UI health in percents and numbers
Tøxicity
Korgath
Tøxicity
90 Human Warlock
9115
Edited by Tøxicity on 10/3/12 3:53 PM (PDT)
I've been trying to get this in a script for some time now, I had one working for it before but in the last few patches it stopped doing its job. Today I got a new version (posted below) from vanguards' stream although it is quite long. I'm not sure where to split it for a new macro or if there is a way to get it in something with more space than 255 characters. Please post any assistance if you can. :)

EDIT: I know the script below works because vanguards' uses it, he posted this in his stream chat which is where I copied it from.

The full script is:

FrameList = {"Player", "Target", "Focus"} function UpdateHealthValues(...) for i = 1, select("#", unpack(FrameList)) do local FrameName = (select(i, unpack(FrameList))) if UnitHealth(FrameName) < 1000 then local Health = UnitHealth(FrameName) local HealthMax = UnitHealthMax(FrameName) else local Health = (UnitHealth(FrameName))/1000 local HealthMax = (UnitHealthMax(FrameName))/1000 local HealthPercent = (UnitHealth(FrameName)/UnitHealthMax(FrameName))*100 if UnitHealth(FrameName) < 1000 then _G[FrameName.."FrameHealthBar"].TextString:SetText(Health.." / "..HealthMax.." ("..format("%.0f",HealthPercent).."%)") else _G[FrameName.."FrameHealthBar"].TextString:SetText(format("%.0f",Health).."k / "..format("%.0f",HealthMax).."k ("..format("%.0f",HealthPercent).."%)") end end end end hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", UpdateHealthValues)
90 Gnome Warrior
11420
I couldn't get it under 255 characters. But here it is rewritten into two macros:

/run FrL={PlayerFrameHealthBar=1,FocusFrameHealthBar=1,TargetFrameHealthBar=1}

/run hooksecurefunc("TextStatusBar_UpdateTextStringWithValues",function(f,t,v,_,x)local z,s,a,k=1000 if FrL[f:GetName()]then a=v*100/x k=x>z s=k and "k"or ""v=k and v/z or v x=k and x/z or x t:SetText(format("%.0f%s / %.0f%s (%.0f%%)",v,s,x,s,a))end end)

The script you posted is pretty cool. But the function TextStatusBar_UpdateTextStringWithValues passes the fontstring (second parameter) on the bar (first parameter), with the current value (third parameter) and max value (fifth parameter), so there were a lot of redundant bits (especially with the concatenated formats and the loop through all three bars every time any bar is updated).

So this:
FrameList = {"Player", "Target", "Focus"}
function UpdateHealthValues(...)
for i = 1, select("#", unpack(FrameList)) do
local FrameName = (select(i, unpack(FrameList)))
if UnitHealth(FrameName) < 1000 then
local Health = UnitHealth(FrameName)
local HealthMax = UnitHealthMax(FrameName)
else
local Health = (UnitHealth(FrameName))/1000
local HealthMax = (UnitHealthMax(FrameName))/1000
local HealthPercent = (UnitHealth(FrameName)/UnitHealthMax(FrameName))*100
if UnitHealth(FrameName) < 1000 then
_G[FrameName.."FrameHealthBar"].TextString:SetText(Health.." / "..HealthMax.." ("..format("%.0f",HealthPercent).."%)")
else
_G[FrameName.."FrameHealthBar"].TextString:SetText(format("%.0f",Health).."k / "..format("%.0f",HealthMax).."k ("..format("%.0f",HealthPercent).."%)")
end
end
end
end
hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", UpdateHealthValues)


can also be:
FrL={PlayerFrameHealthBar=1,FocusFrameHealthBar=1,TargetFrameHealthBar=1}
hooksecurefunc("TextStatusBar_UpdateTextStringWithValues",function(f,t,v,m,x)
local z,s,a,k=1000
if FrL[f:GetName()] then
a=v*100/x
k=x>z
s=k and "k" or ""
v=k and v/z or v
x=k and x/z or x
t:SetText(format("%.0f%s / %.0f%s (%.0f%%)",v,s,x,s,a))
end
end)
Moofaza
Arthas
Moofaza
90 Tauren Druid
7715
/run FrL={PlayerFrameHealthBar=1,FocusFrameHealthBar=1,TargetFrameHealthBar=1}

/run hooksecurefunc("TextStatusBar_UpdateTextStringWithValues",function(f,t,v,_,x)local z,s,a,k=1000 if FrL[f:GetName()]then a=v*100/x k=x>z s=k and "k"or ""v=k and v/z or v x=k and x/z or x t:SetText(format("%.0f%s / %.0f%s (%.0f%%)",v,s,x,s,a))end end)


Been looking for this forever! Thank you so much!
Ghellscream
Mal'Ganis
Ghellscream
90 Undead Warrior
7810
Edited by Ghellscream on 1/16/13 12:23 PM (PST)
I couldn't get it under 255 characters. But here it is rewritten into two macros:

/run FrL={PlayerFrameHealthBar=1,FocusFrameHealthBar=1,TargetFrameHealthBar=1}

/run hooksecurefunc("TextStatusBar_UpdateTextStringWithValues",function(f,t,v,_,x)local z,s,a,k=1000 if FrL[f:GetName()]then a=v*100/x k=x>z s=k and "k"or ""v=k and v/z or v x=k and x/z or x t:SetText(format("%.0f%s / %.0f%s (%.0f%%)",v,s,x,s,a))end end)



dude ty so much for the /run scripts :D

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Click here to view the Forums Code of Conduct.

Report Post # written by
Reason
Explain (256 characters max)

Reported!

[Close]