TL/DR
I am looking for a Lua:Event that gets triggered when Target of target changes.
What am I trying to achieve?
I am making a UI that has no Unit Frames (edit: or action bars), only Nameplates. All the functionality I can get with WA and Nameplate addons. The only thing I'm missing is a Target of target indicator on my Target's nameplate.
What have I tried so far?
I have written a small addon that does show Target of target correctly. But it doesn't update whenever Target of target changes. I couldn't find the event that gets triggered by tot-change on Wowpedia or the forums.
Here's the code I've got so far:
Lua Code:
local npToT = CreateFrame("Frame", NameplateToT, UIParent);
local font = "Interface\\Addons\\NameplateTargetOfTarget\\Rubik-Medium.ttf";
npToT.text = npToT:CreateFontString(nil, "OVERLAY");
local function npToT_EventHandler(self, event, ...)
self.text:ClearAllPoints();
if (C_NamePlate.GetNamePlateForUnit("target") and UnitExists("targettarget")) then
local targetnameplate = C_NamePlate.GetNamePlateForUnit("target");
self.text:Show();
self.text:SetSize(100, 20);
self.text:SetFont(font, 12, "OUTLINE");
self.text:SetFormattedText(UnitName("targettarget"))
self.text:SetPoint("CENTER", targetnameplate, "CENTER", -40, -10);
else
self.text:Hide();
end
end
npToT:SetScript("OnEvent", npToT_EventHandler);
-- Which events do I need to add here?
npToT:RegisterEvent("ADDON_LOADED");
npToT:RegisterEvent("PLAYER_ENTERING_WORLD");
npToT:RegisterEvent("PLAYER_TARGET_CHANGED");
It would be nice to work both in and out of combat, for friendly and hostile targets.
What are some alternative solutions to the problem?
I know Plater can show target of a unit when casting, but I'd like to have it show tot at all times.
TL/DR at the top of the post.