View Single Post
02-14-09, 12:58 PM   #724
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Lykofos View Post
OK, a bit of a newbie at Lua here. I am currently using Wimp's oUF_Faith layout and been slowly mutating to my taste (it maybe time to branch it off into its project, however that is the future..

What I am looking for is how do I show HP color (aka green for full HP, red for low HP, etc.) for my HP text.? Likewise how would I show Power color (Runic, Mana) etc for Power text?

I would prefer a tag as that is how I am tinkering with the layout in question. Likely someone has already tackled this in the past however my SearchFu is lacking today. I did a look through both this thread and WoWWiki however I did not find what was looking for (likely did not look at the right post/article/function ). I also looked through the prebuilt tags (in oUF\elements\tags.lua), however again I did not find what I was looking for.

Just link me to the post or other resource then I will take it from here.
Im using this tag for oUF P3lim

Code:
local function Hex(r, g, b)
	if(type(r) == 'table') then
		if(r.r) then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end
	end
	return string.format('|cff%02x%02x%02x', r*255, g*255, b*255)
end

oUF.Tags['[colorpp]'] = function(u) local n,s = UnitPowerType(u) return Hex(colors.power[s]) end