Thread Tools Display Modes
03-11-24, 12:46 PM   #1
ahbe
A Defias Bandit
Join Date: Feb 2021
Posts: 3
Initially Black Raid Frames, turn into class color when (buff) is applied.

Hey guys!

Trying to find the right logic and events to use for this specific action, I will continue to build onto the addon using the same logic and using colors to navigate through dispells buffs etc on raidframes.

Im not interested in vuhdo or grid thats why im attempting this myself.

Troubleshoot:

The code below turns my raid frames black initially but wont respond and change to class color when I apply power word: shield. Im using chatgpt and scanning the code for mistakes but since as a newbie i just cant find my way around this <3


------------

local frame = CreateFrame("Frame")

frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("UNIT_AURA")

frame:SetScript("OnEvent", function(self, event, unit)
if event == "PLAYER_LOGIN" then

-- Set class colors to black initially for all raid and party members

for _, colorTable in pairs(RAID_CLASS_COLORS) do
colorTable.r, colorTable.g, colorTable.b = 0, 0, 0
colorTable.colorStr = "000000"
end
elseif event == "UNIT_AURA" and (unit == "player" or UnitInParty(unit) or UnitInRaid(unit)) then
local hasPowerWordShield = false

for i = 1, 40 do
local _, _, _, _, _, _, _, _, _, spellID = UnitAura(unit, i, "HELPFUL")
if spellID and spellID == 17 then

-- Replace 17 with the actual spell ID of Power Word: Shield

hasPowerWordShield = true
break
end
end

local _, class = UnitClass(unit)
local colorTable = RAID_CLASS_COLORS[class]

if colorTable then
if hasPowerWordShield then

-- Update the class color when Power Word: Shield is applied

colorTable.r, colorTable.g, colorTable.b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b
colorTable.colorStr = RAID_CLASS_COLORS[class].colorStr
else

-- Set class colors to black if Power Word: Shield is not applied

colorTable.r, colorTable.g, colorTable.b = 0, 0, 0
colorTable.colorStr = "000000"
end
end
end
end)

Last edited by ahbe : 03-11-24 at 12:51 PM.
  Reply With Quote
03-11-24, 01:41 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
Both
Lua Code:
  1. for _, colorTable in pairs(RAID_CLASS_COLORS) do
and
Lua Code:
  1. local colorTable = RAID_CLASS_COLORS[class]
are making changes directly into the global RAID_CLASS_COLORS table. That will change the colour for everything else in the UI using RAID_CLASS_COLORS and it will always be black for everything.

All your actions in both PLAYER_LOGIN and UNIT_AURA just keep changing this global table's colours to black again and again....

Lua Code:
  1. colorTable.r, colorTable.g, colorTable.b = 0, 0, 0

is exactly the same as:

Lua Code:
  1. RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b = 0, 0, 0

and
Lua Code:
  1. colorTable.r, colorTable.g, colorTable.b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b

is exactly the same as:

Lua Code:
  1. RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b

You need to work at the point you want to set the colour of a texture and decide what you want to do with colouring.
eg:
Lua Code:
  1. local classColor = RAID_CLASS_COLORS[class]
  2. if hasPowerWordShield then
  3.     sometexture:SetVertexColor(classColor.r, classColor.g, classColor.b) -- use default
  4. else
  5.     sometexture:SetVertexColor(0, 0, 0) -- set to black
  6. end

And don't do anything at PLAYER_LOGIN
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 03-11-24 at 04:34 PM.
  Reply With Quote
03-12-24, 03:11 AM   #3
sirpucna
An Aku'mai Servant
Join Date: Nov 2016
Posts: 34
i went down a similar path to you to for dark blizz frames, check out a project on curseforge called 'Blizzard Raid Frames - Debuff Highlight By slothpala' to get you started

using the above project as a base, heres my mod i did for dark frames

Code:
local restoreColor = function() end
local function updateRestoreColor()

	restoreColor = function(frame)
		blockColorUpdate[frame] = false
		frame.healthBar:SetStatusBarColor(0.192, 0.2, 0.219)
	end
end
keep in mind hooking "CompactUnitFrame_UpdateHealthColor" is quite expensive CPU wise

you will have to make other changes like converting the background to light color etc

Last edited by sirpucna : 03-12-24 at 03:14 AM.
  Reply With Quote
03-13-24, 07:30 AM   #4
ahbe
A Defias Bandit
Join Date: Feb 2021
Posts: 3
Thank you! I will study a bit more and share my progress.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Initially Black Raid Frames, turn into class color when (buff) is applied.


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