Remove Advertisements

PitBull4 : LUA Text Health color

All things /script related

Moderators: Fridmarr, Worldie, Aergis, _Chloe

PitBull4 : LUA Text Health color

Postby Ezharon » Thu Apr 14, 2011 11:52 pm

I'd like to change my health text color according to my health level. Does anybody know how to do this with LUA Text?
Loatr Tankadin since patch 1.9
Ezharon
 
Posts: 92
Joined: Mon Nov 19, 2007 9:52 pm
Location: New Caledonia

Re: PitBull4 : LUA Text Health color

Postby Raeli » Thu Apr 28, 2011 7:46 pm

Code: Select all
local cur,max = HP(unit), MaxHP(unit)
local diff = max-cur
local pct = cur/max
local color = 0
if pct == 1.0 or pct == 0.0 then
    color = 0xFFFFFF
elseif ( pct <= 0.50 ) then
    color = 0xFF0030 + floor(pct*255)*512
else
    color = 0x10FF30 + floor((1-pct)*235)*(131072)
end
return "|cff%x%s%%", color, Percent(cur,max)


White if 100% or 0%. Green to Red as health percent goes down.
Raeli
 
Posts: 124
Joined: Wed Oct 31, 2007 10:23 pm

Re: PitBull4 : LUA Text Health color

Postby RedAces » Fri Apr 29, 2011 3:55 am

hey,

There's a function built-in in Pitbull for this: HPColor(cur, max)!

simple colored percentage:
Code: Select all
local cur, max = HP(unit), MaxHP(unit)
local r,g,b = HPColor(cur, max)
return "|cff%02x%02x%02x%s%%|r",r,g,b,Percent(cur,max)


Bye, RedAces.
Image
User avatar
RedAces
 
Posts: 500
Joined: Tue Dec 01, 2009 9:39 am
Location: Germany

Re: PitBull4 : LUA Text Health color

Postby Ezharon » Fri Apr 29, 2011 3:37 pm

Thanks 8)
Loatr Tankadin since patch 1.9
Ezharon
 
Posts: 92
Joined: Mon Nov 19, 2007 9:52 pm
Location: New Caledonia


Return to Add-ons, UI, and Macros

Who is online

Users browsing this forum: No registered users and 1 guest


Remove Advertisements

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 380 on Tue Oct 14, 2008 6:28 pm

Users browsing this forum: No registered users and 1 guest