Change A Text-Weakaura's Color Depending On Buff Stacks (Custom Lua)
Warlock here who wants a text-weakaura that shows the current cast time of Chaos Bolt (which I have gotten to work) but also wants the color of this text to turn red whenever I have more than 2 stacks of the Backdraft buff on me.
I have made a Weakaura that is a text-type, the display text is %c (since it is returned from the custom function) which looks as follows:
local _, _, _, _, _, _, currentCastTime, _, _ = GetSpellInfo(116858)
local actualCastTime = currentCastTime*0.001
return (string.format("%.1f", actualCastTime))
And this weakaura is set to trigger all the time when I am alive, so it updates constantly. It works as it should, it shows a digit 2.4 and this changes to for example 1.8 when I get Heroism on me. On top of all this I want the textcolor of this text-Weakaura to change to a different color (red) whenever I have 2 or more stacks of the buff Backdraft on me.
To do this I have in the Animations tab under Main picked Custom Function, set the color to red and entered this custom code:
function(progress, r1, g1, b1, a1, r2, g2, b2, a2)
local stacks = select(4, UnitBuff("player","Backdraft"))
if stacks > 2 then
return r2, g2, b2, a2
return r1,g1,b1, a1
In my mind this ought to work - and funnily enough it does if I use the same Backdraft-function on for example a Progress bar for one of my procs, the progress bar successfully changes color to red depending on my Backdraft stacks - what I can't figure out is why this wont work on a text-Weakaura (but does work on a progress bar-Weakaura).