WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Code works but not 100% yet (https://www.wowinterface.com/forums/showthread.php?t=53277)

EvilMaddness 03-29-16 05:11 PM

Code works but not 100% yet
 
I was able to get the color code to work on the health text but it's changing color when clicking on a target or switching from yellow to green also. I was going to use the same code to change the color for the power text but I'm not any good at lua programming.

Code:

hooksecurefunc("TextStatusBar_UpdateTextStringWithValues",function(statusFrame, _, value, valueMin, valueMax)
 local statusFrame = PlayerFrameHealthBarText
 if statusFrame and PlayerFrameHealthBarTextLeft and PlayerFrameHealthBarTextRight then
 local percent = value / valueMax
 local r,g,b = 1,0.82,0 -- yellow
 if percent < 0.335 then
 r,g,b = 1,0,0 -- red
 elseif percent > 0.665 then
 r,g,b = 0,1,0 -- green
 end
 PlayerFrameHealthBarTextLeft:SetTextColor(r,g,b)
 PlayerFrameHealthBarTextRight:SetTextColor(r,g,b)
 end
end)



All times are GMT -6. The time now is 06:22 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI