Quantcast
WoWInterface - View Single Post - Nameplate hacking and unit IDs
View Single Post
05-14-16, 06:43 PM   #2
syncrow
A Flamescale Wyrmkin
 
syncrow's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 149
Originally Posted by MunkDev View Post
Any suggestions on how to solve this, if it's even possible?
Lua Code:
  1. local activeUnitPlates = {}
  2.  
  3. local function AddNameplate(unitID)
  4.     local nameplate = C_NamePlate.GetNamePlateForUnit(unitID)
  5.     local unitframe = nameplate.UnitFrame
  6.  
  7.     -- store nameplate and its unitID
  8.     activeUnitPlates[unitframe] = unitID
  9. end
  10.  
  11. local function RemoveNameplate(unitID)
  12.     local nameplate = C_NamePlate.GetNamePlateForUnit(unitID)
  13.     local unitframe = nameplate.UnitFrame
  14.    
  15.     -- recycle the nameplate
  16.     activeUnitPlates[unitframe] = nil
  17. end
  18.  
  19. local frame = CreateFrame("Frame")
  20. frame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  21. frame:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
  22.  
  23. frame:SetScript("OnEvent", function(self,event,...)
  24.     if event == "NAME_PLATE_UNIT_ADDED" then
  25.         local unitID = ...
  26.         AddNameplate(unitID)
  27.     end
  28.    
  29.     if event == "NAME_PLATE_UNIT_REMOVED" then
  30.         local unitID = ...
  31.         RemoveNameplate(unitID)
  32.     end
  33. end

This is hopefully what are looking for!

I'm currently constructing new plates for my UI with animated health bars and such things...
The new system is freaking awesome, and very handy!
__________________

Last edited by syncrow : 05-14-16 at 07:14 PM.