Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-07-08, 06:27 AM   #11
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by saulhudson View Post
Hi guys

How can I colour the health text value by there health status.

So for say 2890 hp or 30% make the text red. Not the bar colour but the text itself.

I currently basically do this atm.

bar.value:SetText("|cff33EE44"..numberize(cur) .."|r.".. d.."%")

Which is Lyns code giving something like this 5000.50%.

Any help greatlt appreciated.
Stick this at the top of your layout somewhere.

Code:
local function ColourGradient(perc) -- for colouring in
	if perc <= 0.5 then
		return 255, perc*510, 0
	else
		return 510 - perc*510, 255, 0
	end
end
and then replace
Code:
bar.value:SetText("|cff33EE44"..numberize(cur) .."|r.".. d.."%")
with
Code:
bar.value:SetText(string.format("|cff%02x%02x%02x%s|r.%s%%", ColourGradient(min/max), numberize(cur), d)
Hope this helps.
 
 

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF - Layout discussion


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