Thread Tools Display Modes
01-11-23, 03:47 AM   #1
Just_a_Lurker
A Kobold Labourer
Join Date: Jan 2023
Posts: 1
Weakaura code help

So I'm not the original creator of this Weakaura, I can't remember where it's from unfortunately so I can't contact the creator of it either. This currently attaches a Diminishing Return icon next to nameplates, it's exactly what I want. BUT this also applies to friendly nameplates. I want that feature removed, and make it so it's only attached to Enemy / Attackable nameplates.

This is the code inside Trigger -> Custom -> Trigger State Updater(Advanced) -> Event(s) -> COMBAT_LOG_EVENT_UNFILTERED, NAME_PLATE_UNIT_ADDED, NAME_PLATE_UNIT_REMOVED, PLAYER_REGEN_DISABLED, PLAYER_REGEN_ENABLED

Then this is inside the custom trigger there's this
"function(allstates, event, ...)
if event == 'PLAYER_REGEN_DISABLED' or event == 'PLAYER_REGEN_ENABLED' then
aura_env.clean_drs()
return false
end


if event == "NAME_PLATE_UNIT_ADDED" then
local np = select(1, ...)
return aura_env.track_plate(allstates, np)
end

if event == "NAME_PLATE_UNIT_REMOVED" then
local np = select(1, ...)
return aura_env.untrack_plate(allstates, np)
end

if event ~= 'COMBAT_LOG_EVENT_UNFILTERED' then
aura_env.debug('returning early from event ' .. event)
return

end
local sub_event = select(2, ...)


if sub_event == "UNIT_DIED" then
local dest_guid = select(8, ...)
return aura_env.untrack_guid(allstates, dest_guid)
end


if sub_event == 'SPELL_AURA_REMOVED' or sub_event == 'SPELL_AURA_REFRESH' then
return aura_env.check_aura(allstates, ...)
end




end




Is there anything in that code that can be changed to only apply to enemies?

Here's the entire Weakaura, might be easier - https://wago.io/VA0oXiTQ5
  Reply With Quote
01-14-23, 06:20 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
NAME_PLATE_UNIT_ADDED fires with a UnitID for what the nameplate is attached to. You can add a check on that by adding the highlighted lines to this code block.

Code:
if event == "NAME_PLATE_UNIT_ADDED" then
	local np = select(1, ...)
	if UnitIsEnemy("player", np) then
		return aura_env.track_plate(allstates, np)
	end
end
Note: The return is safe to skip as the code exits soon after anyway when it checks if it's a CLEU event.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 01-14-23 at 06:23 AM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Weakaura code help

Thread Tools
Display Modes

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