Topic
UI health in percents and numbers
|
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) |
|
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"}can also be: FrL={PlayerFrameHealthBar=1,FocusFrameHealthBar=1,TargetFrameHealthBar=1}
|
|
|
/run FrL={PlayerFrameHealthBar=1,FocusFrameHealthBar=1,TargetFrameHealthBar=1} Been looking for this forever! Thank you so much! |
|
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: dude ty so much for the /run scripts :D |
