Help with addon that displays a "Spell Steal" border

Hello - I’ve been using an addon since Legion that would display the Spell Steal border or a Purgable Spell border for classes that do not have a purge but it no longer works. I was wondering if anyone could tell me what’s wrong with the addon now. Here is the code:

hooksecurefunc("TargetFrame_UpdateAuras", function(s)
    for i = 1, MAX_TARGET_BUFFS do
        _, ic, _, dT = UnitBuff(s.unit, i)
        if(ic and (not s.maxBuffs or i<=s.maxBuffs)) then
            fS=_G[s:GetName()..'Buff'..i..'Stealable']
            if(UnitIsEnemy(PlayerFrame.unit, s.unit) and dT=='Magic') then
                fS:Show()
            else
                fS:Hide()
            end
        end
    end
end)

Thanks!

Try

hooksecurefunc(TargetFrame,"UpdateAuras", function(s)
    for i = 1, MAX_TARGET_BUFFS do
        _, ic, _, dT = UnitBuff(s.unit, i)
        if(ic and (not s.maxBuffs or i<=s.maxBuffs)) then
            fS=_G[s:GetName()..'Buff'..i..'Stealable']
            if(UnitIsEnemy(PlayerFrame.unit, s.unit) and dT=='Magic') then
                fS:Show()
            else
                fS:Hide()
            end
        end
    end
end)

Thanks, I think that fixed the function issue but now it’s coming up with the error: Interface/AddOns/SpellStealAura/SpellStealAura.lua:55: attempt to index global 'fS' (a nil value)

hooksecurefunc(TargetFrame,"UpdateAuras", function(s)
	for i = 1, MAX_TARGET_BUFFS do
		_, ic, _, dT = UnitBuff(s.unit, i)
		if (ic and (not s.maxBuffs or i<=s.maxBuffs)) then
			local fS = _G[s:GetName()..'Buff'..i..'Stealable']
			if (UnitIsEnemy(PlayerFrame.unit, s.unit) and dT=='Magic') then
				fS:Show()
			else
				fS:Hide()
			end
		end
	end
end)

I got another error: SpellStealAura/SpellStealAura.lua:55: attempt to index local 'fS' (a nil value)

hooksecurefunc(TargetFrame,"UpdateAuras", function(s)
	for i = 1, MAX_TARGET_BUFFS do
		_, ic, _, dT = UnitBuff(s.unit, i)
		if(ic and (not s.maxBuffs or i<=s.maxBuffs)) then
			local fS = _G[s:GetName()..'Buff'..i..'Stealable']
			if(UnitIsEnemy(PlayerFrame.unit, s.unit) and dT=='Magic') then
				fS:Show()
			else
				fS:Hide()
			end
		end
	end
end)

Yeah, it’s been totally reworked.
Old:
https://github.com/Gethe/wow-ui-source/blob/b07ebaf2f4bf6b62df5da3937f42942873438583/Interface/FrameXML/TargetFrame.lua#L510

Current:
https://github.com/Gethe/wow-ui-source/blob/bdf9c61809fe5d30bf266e8961e1e8cb8f52499e/Interface/FrameXML/TargetFrame.lua#L543

Ah, does that mean it’s not possible to fix? Thank you for all your help btw.

It’s likely still possible, just beyond my knowledge level.

Hello, just trying to bump this thread again to see if anyone has any ideas. Thanks!

This response is rubbish. see:

Rubbish response below:

These seem to have moved to pools. You could rebuild the code based on iterating through the buffs pool for the target. Something (untested) like:

local i=0 
for frame in TargetFrame.auraPools:GetPool("TargetBuffFrameTemplate"):EnumerateActive() do 
	i = i + 1
	local _, ic, _, dT = UnitBuff("target", i)
	if(UnitIsEnemy("player", "target") and dT=='Magic') then
		frame.Stealable:Show()
	else
		frame.Stealable:Hide()
	end
end