View Single Post
12-03-08, 10:08 AM   #277
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by ObbleYeah View Post
I'm getting a small issue with colouring my portrait overlay texture for my layout. As you can in the picture (http://i36.tinypic.com/33yjey8.jpg) It colours by class quite happily but it paints normal mobs a quite unhealthy black. I want to get it so it colours by Unit Selection.
Code:
if UnitIsPlayer(unit) then
	  local _, class = UnitClass(unit)
	  t = self.colors.class[class]
	elseif(not UnitIsPlayer(unit)) then
	  	elseif(not UnitIsPlayer(unit)) then
		local targetLevel = UnitLevel("target"); ----- Test.
		t = GetDifficultyColor(targetLevel)
	 end
	  if (t) then
	  r, g, b = t[1], t[2], t[3]
	  else
	  r, g, b = {.7,.7,.7}
    end
	self.Health.bg:SetVertexColor(r,g,b)
	if(unit=='player' or unit=='target') then 
	self.Portraitglosst:SetVertexColor(r,g,b)   	
	end
Is what i use to colour it at the minute, and i have also tried
Code:
    if UnitIsPlayer(unit) then
	  local _, class = UnitClass(unit)
	  t = self.colors.class[class]
	elseif(not UnitIsPlayer(unit)) then
	  	elseif(not UnitIsPlayer(unit)) then
		t = UnitSelectionColor(unit)
	 end
	  if (t) then
	  r, g, b = t[1], t[2], t[3]
               end
	self.Health.bg:SetVertexColor(r,g,b)
             if(unit=='player' or unit=='target') then 
	self.Portraitglosst:SetVertexColor(r,g,b)
           end
Any ideas whats causing it to do this?
First off, your code is far from readable, took me a bit to read that piece of code.

Try the following
Code:
local color
if(UnitIsPlayer(unit)) then
	local localized, english = UnitClass(unit)
	color = self.colors.class[english]
else
	color = UnitSelectionColor(unit)
end

self.Health.bg:SetVertexColor(unpack(color))

if(self.Portraitglosst) then
	self.Portraitglosst:SetVertexColor(unpack(color))
end