Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-29-24, 08:53 AM   #1
grog162
A Defias Bandit
Join Date: Apr 2024
Posts: 3
Lua Event for Target of target Change, Nameplate addon

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:
  1. local npToT = CreateFrame("Frame", NameplateToT, UIParent);
  2. local font = "Interface\\Addons\\NameplateTargetOfTarget\\Rubik-Medium.ttf";
  3.  
  4. npToT.text = npToT:CreateFontString(nil, "OVERLAY");
  5.  
  6. local function npToT_EventHandler(self, event, ...)
  7.     self.text:ClearAllPoints();
  8.     if (C_NamePlate.GetNamePlateForUnit("target") and UnitExists("targettarget")) then
  9.         local targetnameplate = C_NamePlate.GetNamePlateForUnit("target");
  10.         self.text:Show();
  11.         self.text:SetSize(100, 20);
  12.         self.text:SetFont(font, 12, "OUTLINE");
  13.         self.text:SetFormattedText(UnitName("targettarget"))
  14.         self.text:SetPoint("CENTER", targetnameplate, "CENTER", -40, -10);
  15.     else
  16.         self.text:Hide();
  17.     end
  18. end
  19.  
  20. npToT:SetScript("OnEvent", npToT_EventHandler);
  21.  
  22. -- Which events do I need to add here?
  23. npToT:RegisterEvent("ADDON_LOADED");
  24. npToT:RegisterEvent("PLAYER_ENTERING_WORLD");
  25. 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.

Last edited by grog162 : 04-29-24 at 09:14 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Lua Event for Target of target Change, Nameplate addon


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