Thread Tools Display Modes
11-30-14, 04:53 AM   #1
mich125
A Fallenroot Satyr
Join Date: Jan 2010
Posts: 27
Hp percent display script.

Hello,

I have my own way i like to display hp on target focus etc. Below is the script that i use, thing is if target/focus is dead it will keep displaying 0% over DEAD text. Can someone fix this for target/focus, if they are dead to stop displaying it. THX!

http://i.imgur.com/LfZizjh.jpg

Code:
hooksecurefunc("TextStatusBar_UpdateTextStringWithValues",function(f,t,v,_,x)
if f==TargetFrameHealthBar or f==FocusFrameHealthBar or f==PlayerFrameHealthBar then
 local V,z,Z=v,1000 Z=z*z
 local F=format
 v = (v>Z and F("%.2fM",v/Z)) or (v>(z*10) and F("%.0fk",v/z)) or v
 t:SetText(F("%s (%.0f%%)",v,V*100/x))
end
end)
  Reply With Quote
11-30-14, 09:35 AM   #2
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Try this:
Lua Code:
  1. hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", function(statusFrame, textString, value, valueMin, valueMax)
  2.     if statusFrame == PlayerFrameHealthBar or ((statusFrame == TargetFrameHealthBar or statusFrame == FocusFrameHealthBar) and not UnitIsDeadOrGhost(statusFrame:GetParent().unit)) then
  3.         local formattedValue = (value > 1e6 and ("%.2fM"):format(value / 1e6)) or (value > 1e4 and ("%.0fk"):format(value / 1e3)) or value
  4.         textString:SetFormattedText("%s (%.0f%%)", formattedValue, value * 100 / valueMax)
  5.     end
  6. end)

I had to rename all the variables and reformat the code because the one-letter names and strange space-saving arithmetic operations made it very difficult to read.
  Reply With Quote
11-30-14, 11:25 AM   #3
mich125
A Fallenroot Satyr
Join Date: Jan 2010
Posts: 27
Seems to work nicely, thx m8<3
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Hp percent display script.


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