Hello,
right now, I use this script for changing a panel's color depending on target's class (in OnUpdate):
Code:
local _, class = UnitClass("target");
if class == "WARRIOR" then
self.bg:SetVertexColor(0.95, 0.23, 0.23, self.bg:GetAlpha())
elseif class == "PRIEST" then
self.bg:SetVertexColor(1, 0.96, 0.98, self.bg:GetAlpha())
elseif class == "MAGE" then
self.bg:SetVertexColor(0.00, 1, 1, self.bg:GetAlpha())
elseif class == "DRUID" then
self.bg:SetVertexColor(1, 0.49, 0.04, self.bg:GetAlpha())
elseif class == "PALADIN" then
self.bg:SetVertexColor(0.92, 0.22, 0.46, self.bg:GetAlpha())
elseif class == "HUNTER" then
self.bg:SetVertexColor(0.33, 0.86, 0.00, self.bg:GetAlpha())
elseif class == "ROGUE" then
self.bg:SetVertexColor(1, 0.94, 0.16, self.bg:GetAlpha())
elseif class == "SHAMAN" then
self.bg:SetVertexColor(0.13, 0.42, 1, self.bg:GetAlpha())
elseif class == "WARLOCK" then
self.bg:SetVertexColor(0.36, 0.18, 1, self.bg:GetAlpha())
elseif class == "DEATHKNIGHT" then
self.bg:SetVertexColor(1, 0.00, 0.00, self.bg:GetAlpha())
end
Works perfectly, except for NPCs since they are usually 3 classes - warrior, paladin and mage.
What I want to do is to make it show color depending on it's reaction (friendly, neutral, hostile etc.)
So I wrote this...
Code:
local _, reaction = UnitReaction("target", "player");
if reaction == "1" then
self.bg:SetVertexColor(1, 0.00, 0.00, self.bg:GetAlpha())
elseif reaction == "2" then
self.bg:SetVertexColor(1, 0.00, 0.00, self.bg:GetAlpha())
elseif reaction == "3" then
self.bg:SetVertexColor(1, 0.00, 0.00, self.bg:GetAlpha())
elseif reaction == "4" then
self.bg:SetVertexColor(1, 0.49, 0.04, self.bg:GetAlpha())
elseif reaction == "5" then
self.bg:SetVertexColor(0.33, 0.86, 0.00, self.bg:GetAlpha())
elseif reaction == "6" then
self.bg:SetVertexColor(0.33, 0.86, 0.00, self.bg:GetAlpha())
elseif reaction == "7" then
self.bg:SetVertexColor(0.33, 0.86, 0.00, self.bg:GetAlpha())
elseif reaction == "8" then
self.bg:SetVertexColor(0.33, 0.86, 0.00, self.bg:GetAlpha())
end
...what unfortunately doesn't work at all.
What am I doing wrong and how can I merge this script with the one above?
My second question is how to make a (different) panel switch texture - again, depending on class, but as for NPCs - depending on classification (normal, rare, elite, boss). I have really no idea how the script should look like...
Thanks in advance!