View Single Post
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