Thread Tools Display Modes
09-18-15, 07:55 AM   #1
kawe
A Cyclonian
 
kawe's Avatar
Join Date: Sep 2009
Posts: 40
oUF_lumen

hi,

i have a question regarding aurabar(buff) colouring;

Code:
if(reaction == 'HARMFUL') then
	if(cfg.BarTimers_Color_by_Debuff) then
	local debufftype = bar.timer.debuffType
	local color = DebuffTypeColor[debufftype] or DebuffTypeColor.none
	bar:SetStatusBarColor(color.r, color.g, color.b)
	bar.spark:SetVertexColor(color.r, color.g, color.b)
else
	bar:SetStatusBarColor(1, 0, 0)
	bar.spark:SetVertexColor(1, 0, 0)
end
        else
	bar:SetStatusBarColor(0.15, 0.35, 0.55)
	bar.spark:SetVertexColor(0.15, 0.35, 0.55)
end
	bar:Show()
how can i change this code to also show my own buffs in matching color and not just predefined colour?

i tried to copy en edit from another layout but it seems that the more i edit, the more i have to copy from the other layout and if not, i might just install the other layout and use it
  Reply With Quote
09-18-15, 08:06 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
So you want buffs colored by "debuff type" just like debuffs? Just remove the part that checks whether the aura is a debuff, and the part that would run if that check didn't pass:
Code:
if(reaction == 'HARMFUL') then
	if(cfg.BarTimers_Color_by_Debuff) then
		local debufftype = bar.timer.debuffType
		local color = DebuffTypeColor[debufftype] or DebuffTypeColor.none
		bar:SetStatusBarColor(color.r, color.g, color.b)
		bar.spark:SetVertexColor(color.r, color.g, color.b)
	else
		bar:SetStatusBarColor(1, 0, 0)
		bar.spark:SetVertexColor(1, 0, 0)
	end
else
	bar:SetStatusBarColor(0.15, 0.35, 0.55)
	bar.spark:SetVertexColor(0.15, 0.35, 0.55)
end
bar:Show()
If you want something else, please clarify.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
09-18-15, 01:05 PM   #3
kawe
A Cyclonian
 
kawe's Avatar
Join Date: Sep 2009
Posts: 40
Originally Posted by Phanx View Post
So you want buffs colored by "debuff type" just like debuffs? Just remove the part that checks whether the aura is a debuff, and the part that would run if that check didn't pass:
Code:
if(reaction == 'HARMFUL') then
if(cfg.BarTimers_Color_by_Debuff) then
	local debufftype = bar.timer.debuffType
	local color = DebuffTypeColor[debufftype] or DebuffTypeColor.none
	bar:SetStatusBarColor(color.r, color.g, color.b)
	bar.spark:SetVertexColor(color.r, color.g, color.b)
else
	bar:SetStatusBarColor(1, 0, 0)
	bar.spark:SetVertexColor(1, 0, 0)
	end
else
	bar:SetStatusBarColor(0.15, 0.35, 0.55)
	bar.spark:SetVertexColor(0.15, 0.35, 0.55)
end
bar:Show()
If you want something else, please clarify.
hi phanx

i meant colored by "buff type" (my own aura bars/buffs, not the targets) for ex. renew > green, barkskin > yellow etc. Something like this;

Code:
-- Colour bars
	local r, g, b = 0.15, 0.35, 0.55
	if element.statusBarColor then r, g, b = unpack(element.statusBarColor) end
	local bgmulti = 0
	if element.colorTable[aura.spellid] then
		r, g, b = unpack(element.colorTable[aura.spellid])
	elseif element.colorTable[aura.name] then
		r, g, b = unpack(element.colorTable[aura.name])
	end
	bar:SetStatusBarColor(r, g, b)
	bar.bg:SetVertexColor(0,0,0, 0.6)
	bar:Show()
		
	-- Backup the details of the aura onto the bar, so the OnUpdate function 
        can use them 
        bar.aura = aura
i tried to put this code into core file and copy spellid's to the config file but all i get is lua errors. i dont have the lua knowledge to make this work.

Last edited by kawe : 09-18-15 at 01:08 PM.
  Reply With Quote
09-22-15, 12:28 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by kawe View Post
i meant colored by "buff type" (my own aura bars/buffs, not the targets) for ex. renew > green, barkskin > yellow etc. Something like this;
Well, without knowing what variables are declared in the scope where that code is running, I can't write the whole thing for you, but to give you the general idea, put something like this at the top of the file:
Code:
local colors = {
	GREEN  = { r = 0, g = 0.82, b = 0 },
	YELLOW = { r = 1, g = 0.82, b = 0 },
	-- add more colors here
}
local spellColors = {
	[  139] = GREEN,  -- Renew
	[22812] = YELLOW, -- Barkskin
	-- add more spells here
}
(It's not strictly necessary to define the colors separately, but it'll make it easier to maintain once you have a lot of spells listed, and will save a bit of memory since you'll only be defining each color table once instead of 40 times if you have 40 green spells, for example.)

Then in the part you were working with earlier, add something like the part in green:
Code:
if(reaction == 'HARMFUL') then
	if(cfg.BarTimers_Color_by_Debuff) then
		local debufftype = bar.timer.debuffType
		local color = DebuffTypeColor[debufftype] or DebuffTypeColor.none
		bar:SetStatusBarColor(color.r, color.g, color.b)
		bar.spark:SetVertexColor(color.r, color.g, color.b)
	else
		bar:SetStatusBarColor(1, 0, 0)
		bar.spark:SetVertexColor(1, 0, 0)
	end
else
	local color = (unit == 'player') and spellColors[spellID]
	if color then
		bar:SetStatusBarColor(color.r, color.g, color.b)
		bar.spark:SetVertexColor(color.r, color.g, color.b)
	else
		bar:SetStatusBarColor(0.15, 0.35, 0.55)
		bar.spark:SetVertexColor(0.15, 0.35, 0.55)
	end
end
bar:Show()
You'd need to change the "unit" and "spellID" variables according to whatever's being used in your existing code.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
09-24-15, 09:32 AM   #5
kawe
A Cyclonian
 
kawe's Avatar
Join Date: Sep 2009
Posts: 40
thx for the reply, i'll try my best
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF_lumen


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