View Single Post
02-03-16, 04:46 PM   #8
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,334
While conflicts with other addons can happen, it appears not all UnitFrames are running the event-based hook that I used. I changed the hook to come in from a different approach that should run more reliably.
Lua Code:
  1. hooksecurefunc("TextStatusBar_UpdateTextStringWithValues",function(bar,text,val,min,max)
  2.     local name=bar:GetName();
  3.     if name and name:find("HealthBar$") then
  4.         local pcnt=val/max;
  5.         local r,g,b=1,0,0;--    Default red for both bar and text
  6.  
  7.         if pcnt>0.3 then r,g,b=0,1,0; end--  Green bar if >30%
  8.         if not bar.disconnected and not bar.lockColor then bar:SetStatusBarColor(r,g,b); end
  9.  
  10.         if pcnt>0.3 or pcnt<=0 then r,g,b=1,1,1; end--    White text if dead or >30%
  11.         if bar.LeftText then bar.LeftText:SetTextColor(r,g,b); end
  12.         if bar.RightText then bar.RightText:SetTextColor(r,g,b); end
  13.         text:SetTextColor(r,g,b);
  14.     end
  15. 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