Thread Tools Display Modes
11-30-10, 07:30 PM   #1
Kendian
A Molten Giant
 
Kendian's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 614
KGPanels Scripts target

HIyas, Im trying to make a panel (for target UF to be class colored). Meaning, does anyone know the script to make a panel the TARGETS class color? My thanks, in advance for any and all help~

Fake edit: I tried the page at wowace, but no one ever answers questions there >.<
  Reply With Quote
11-30-10, 09:49 PM   #2
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
Writing one, just a sec.

Edit:
Code:
-- OnLoad
self:RegisterEvent("UNIT_TARGET")


-- OnEvent
if (event=="UNIT_TARGET") then
local _, class = UnitClass("target")
	if (class=="DEATHKNIGHT") then
		self.bg:SetVertexColor(0.77, 0.12, 0.23, self.bg:GetAlpha())
	elseif (class=="DRUID") then
		self.bg:SetVertexColor(1,0.49,0.04, self.bg:GetAlpha())
	elseif (class=="HUNTER") then
		self.bg:SetVertexColor(0.67,0.83,0.45, self.bg:GetAlpha())
	elseif (class=="MAGE") then
		self.bg:SetVertexColor(0.41,0.8,0.94, self.bg:GetAlpha())
	elseif (class=="PALADIN") then
		self.bg:SetVertexColor(0.96,0.55,0.73, self.bg:GetAlpha())
	elseif (class=="PRIEST") then
		self.bg:SetVertexColor(1,1,1, self.bg:GetAlpha())
	elseif (class=="ROGUE") then
		self.bg:SetVertexColor(1,0.96,0.41, self.bg:GetAlpha())
	elseif (class=="SHAMAN") then
		self.bg:SetVertexColor(0,0.44,0.87, self.bg:GetAlpha())
	elseif (class=="WARLOCK") then
		self.bg:SetVertexColor(0.58,0.51,0.79, self.bg:GetAlpha())
	elseif (class=="WARRIOR") then
		self.bg:SetVertexColor(0.78,0.61,0.43, self.bg:GetAlpha())
	end
end

Last edited by Waky : 11-30-10 at 09:55 PM.
  Reply With Quote
11-30-10, 10:02 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Waky View Post
Writing one, just a sec.

Edit:
Code:
-- OnLoad
self:RegisterEvent("PLAYER_TARGET_CHANGED")
Fixed. That one there will only fire for your target.

/edit: you also need to change the OnEvent (btw, checking for the event isn't needed since we're only registering for one event anyway)

Code:
-- OnEvent
local _, class = UnitClass("target")
if class then
	if (class=="DEATHKNIGHT") then
		self.bg:SetVertexColor(0.77, 0.12, 0.23, self.bg:GetAlpha())
	elseif (class=="DRUID") then
		self.bg:SetVertexColor(1,0.49,0.04, self.bg:GetAlpha())
	elseif (class=="HUNTER") then
		self.bg:SetVertexColor(0.67,0.83,0.45, self.bg:GetAlpha())
	elseif (class=="MAGE") then
		self.bg:SetVertexColor(0.41,0.8,0.94, self.bg:GetAlpha())
	elseif (class=="PALADIN") then
		self.bg:SetVertexColor(0.96,0.55,0.73, self.bg:GetAlpha())
	elseif (class=="PRIEST") then
		self.bg:SetVertexColor(1,1,1, self.bg:GetAlpha())
	elseif (class=="ROGUE") then
		self.bg:SetVertexColor(1,0.96,0.41, self.bg:GetAlpha())
	elseif (class=="SHAMAN") then
		self.bg:SetVertexColor(0,0.44,0.87, self.bg:GetAlpha())
	elseif (class=="WARLOCK") then
		self.bg:SetVertexColor(0.58,0.51,0.79, self.bg:GetAlpha())
	elseif (class=="WARRIOR") then
		self.bg:SetVertexColor(0.78,0.61,0.43, self.bg:GetAlpha())
	end
end
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh


Last edited by Seerah : 11-30-10 at 10:05 PM.
  Reply With Quote
11-30-10, 10:12 PM   #4
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
Pssh :P Thanks Seerah
  Reply With Quote
11-30-10, 10:14 PM   #5
Kendian
A Molten Giant
 
Kendian's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 614
My thanks, ever so much, both of you~
  Reply With Quote
01-26-11, 09:34 PM   #6
Kendian
A Molten Giant
 
Kendian's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 614
Originally Posted by Seerah View Post
Fixed. That one there will only fire for your target.

/edit: you also need to change the OnEvent (btw, checking for the event isn't needed since we're only registering for one event anyway)

Code:
-- OnEvent
local _, class = UnitClass("target")
if class then
	if (class=="DEATHKNIGHT") then
		self.bg:SetVertexColor(0.77, 0.12, 0.23, self.bg:GetAlpha())
	elseif (class=="DRUID") then
		self.bg:SetVertexColor(1,0.49,0.04, self.bg:GetAlpha())
	elseif (class=="HUNTER") then
		self.bg:SetVertexColor(0.67,0.83,0.45, self.bg:GetAlpha())
	elseif (class=="MAGE") then
		self.bg:SetVertexColor(0.41,0.8,0.94, self.bg:GetAlpha())
	elseif (class=="PALADIN") then
		self.bg:SetVertexColor(0.96,0.55,0.73, self.bg:GetAlpha())
	elseif (class=="PRIEST") then
		self.bg:SetVertexColor(1,1,1, self.bg:GetAlpha())
	elseif (class=="ROGUE") then
		self.bg:SetVertexColor(1,0.96,0.41, self.bg:GetAlpha())
	elseif (class=="SHAMAN") then
		self.bg:SetVertexColor(0,0.44,0.87, self.bg:GetAlpha())
	elseif (class=="WARLOCK") then
		self.bg:SetVertexColor(0.58,0.51,0.79, self.bg:GetAlpha())
	elseif (class=="WARRIOR") then
		self.bg:SetVertexColor(0.78,0.61,0.43, self.bg:GetAlpha())
	end
end
Sigh...I need to wear a helmet in public, I suppose ( my brain is mushy)...how would I apply this to BORDER of targets panel?
  Reply With Quote
01-26-11, 11:04 PM   #7
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
A bit more compact, should work:

-- OnEvent
Code:
local _, Class = UnitClass("target")
local Color = RAID_CLASS_COLORS[Class]
self.bg:SetVertexColor(Color.r, Color.g, Color.b, self.bg:GetAlpha())
As for borders.

-- OnEvent
Code:
local _, Class = UnitClass("target")
local Color = RAID_CLASS_COLORS[Class]
self:SetBackdropBorderColor(Color.r, Color.g, Color.b, self.bg:GetAlpha())
  Reply With Quote
01-26-11, 11:32 PM   #8
Kendian
A Molten Giant
 
Kendian's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 614
How lame is it that I spent 2.5 hours trying to figure this out, lol?
My thanks, Nibleheim, it's much appreciated~
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » KGPanels Scripts target


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off