LUA to check for debuff on target then apply aura to nameplate

Working with Weakauras and a custom trigger function that works so far to display a texture on my current target’s nameplate. The texture is also based on a usable action. Once I employ this function I can no longer use the normal Weakauras interface to create a second trigger condition. This is the LUA that does this successfully

function()
local region = aura_env.region
local plate = C_NamePlate.GetNamePlateForUnit(“target”)
local start, duration, enabled = GetSpellCooldown(“Shield Block”)
if plate then
region:ClearAllPoints()
region:SetPoint(“CENTER”, plate, “CENTER”, 0, 24)
if duration == 0 then
region:Show()
else
region:Hide()
end
else
region:Hide()
end
return true
end

What I am trying to do but am, so far, unable to figure out is to create a similar texture for a debuff on the target. I’ve tried a few API functions but can’t seem to get the following LUA to work.

function()
local region = aura_env.region
local plate = C_NamePlate.GetNamePlateForUnit(“target”)
local db = AuraUtil.FindAuraByName(“Demoralizing Shout”, “target”)
if plate then
region:ClearAllPoints()
region:SetPoint(“CENTER”, plate, “CENTER”, 0, 24)
if db then
region:Hide()
else
region:Show()
end
else
region:Hide()
end
return true
end

The game shows the texture on my targeted nameplate but the texture does not go away when I cast Demoralizing Shout…Can anyone tell me what I’m doing incorrectly?

Try the custom anchor option that was added in September.
https://github.com/WeakAuras/WeakAuras2/wiki/Custom-Anchor

Appreciate the advice. I couldn’t figure out how to make that approach work while having the icon appear on all the mobs in nameplate range. Would only show for the target (which was also the case for my own stuff that worked. For the rotation helper stuff that was fine but for the missing debuff I wanted to see it for everyone around me.)

I went ahead and just used Plater to show the debuffs. Was, I think, the best approach even though what I wanted was to show the texture when the debuff didn’t exist rather than when it did, and to use a WA texture so that it could remain consistent with the look of my rotation stuff…Still, an acceptable solution I suppose.

You can do that without custom code now. Use the normal debuff trigger with unit set to Nameplate and “auto clone” enabled. Put that inside a dynamic group and in the group options check “Group by Frame” and select Nameplates in the dropdown.

wow. thanks. Never realized they had added that!