View Single Post
08-10-10, 01:27 PM   #58
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
Code:
-- Health Function
local updateHealth = function(health, unit, min, max)
        if(max ~= 0) then
                r, g, b = self.ColorGradient(min/max, .69,.31,.31, .65,.63,.35, .33,.59,.33)
        end
 
        if(not UnitIsConnected(unit)) then
                health:SetValue(0)
                health.value:SetText('|cffD7BEA5'..'Offline')
        elseif(unit == 'targettarget' or unit == 'pet' or unit == 'focus') then
                health.value:SetText()
        elseif(UnitIsDead(unit)) then
                health.value:SetText('|cffD7BEA5'..'Dead')
        elseif(UnitIsGhost(unit)) then
                health.value:SetText('|cffD7BEA5'..'Ghost')
        else
                if(min~=max) then
                        health.value:SetFormattedText("|cffAF5050%d|r |cffD7BEA5-|r |cff%02x%02x%02x%d%%|r", (min), r*255, g*255, b*255, (min/max)*100)
               
                else
                        health.value:SetText('|cff559655'..(max))
                end
        end
 
        -- BarColor
        if(max ~= 0)then
          x,y,z = self.ColorGradient((min/max), .65,.25,.25, .25,.25,.25, .25,.25,.25)
        else
          x,y,z = .25,.25,.25
        end
          health:SetStatusBarColor(x,y,z)
end
 
-- Power Function
local updatePower = function(power, unit, min, max)
        if(min == 0 or UnitIsDead(unit) or UnitIsGhost(unit) or unit == 'pet' or unit == 'focus' or not UnitIsConnected(unit)) then
          power.value:SetText()
        else
          power.value:SetFormattedText((min))
        end
        local _, pType = UnitPowerType(unit)
        local color = self.colors.power[pType]
        if(color) then power.value:SetTextColor(color[1], color[2], color[3]) end
end
try this

with
hp.PostUpdate = updateHealth
and
pp.PostUpdate = updatePower

not tested though.
  Reply With Quote