Files
wow-weakauras/WeakAuras/Projects/NameplateStatus/trigger.lua

29 lines
702 B
Lua

-- NAME_PLATE_UNIT_ADDED NAME_PLATE_UNIT_REMOVED
function(states, event, unit, ...)
if event == "NAME_PLATE_UNIT_ADDED" and unit or event == "NAME_PLATE_UNIT_REMOVED" and unit then
local GUID = UnitGUID(unit)
if GUID then
local isPvp = UnitIsPVP(unit)
local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
states[GUID] = {
GUID = GUID,
unit = unit,
frame = nameplate,
progressType = "static",
autoHide = true,
changed = true,
show = isPvp,
}
end
elseif event == "NAME_PLATE_UNIT_REMOVED" and unit then
local GUID = UnitGUID(unit)
local state = states[GUID]
if state then
state.show = false
state.changed = true
end
end
return true
end