My Env Info: WOW 3.4.3 + WA 5.12.8
I'm trying to do some practice for tracking a spell's caster and target
basically I can retrieve sourceGUID, sourceName, destGUID, destName from CLEU:SPELL_CAST_SUCCESS
so next I wanna do this:
sourceUnit = MyFunction(sourceGUID, sourceName) destUnit = sourceUnit .. "target"
then do something else, in this case a sourceUnit/destUnit is required
I've learned several ways to achieve that, for instance using param sourceGUID, assuming that UnitExists(unit) is always true
`1. local unit = "target"
if UnitGUID(unit) == sourceGUID then return unit
-
local unit = "focus"
if UnitGUID(unit) == sourceGUID then return unit -
for i=1, 40 do
local unit = "nameplate"..i
if UnitGUID(unit) == sourceGUID then return unit
end
end -
for _,v in pairs(C_NamePlate.GetNamePlates()) do
local unit = v.namePlateUnitToken
if UnitGUID(unit) == sourceGUID then return unit
end -
for unit in WA_IterateGroupMembers() do
if UnitGUID(unit) == sourceGUID or UnitGUID(unit.."target") == sourceGUID then return unit
end
6.1 for i=1, GetNumSubgroupMembers() do
local unit = "party"..i
if UnitGUID(unit) == sourceGUID or UnitGUID(unit.."target") == sourceGUID then return unit
end
6.2 for i=1, GetNumGroupMembers() do
unit = "raid"..i
if UnitGUID(unit) == sourceGUID or UnitGUID(unit.."target") == sourceGUID then return unit
end`
I understand that I should always check 1 and 2 to quickly get a result, then use 3 or 4, then 5 or 6.1+6.2
wondering is this the best way that we can have in WA?
if so, which performs better comparing 3 and 4, 5 and 6.1+6.2 ?
or anyone can share a better solution please.
thanks in advance!
❤️ ❤️ ❤️