View Single Post
11-01-19, 08:29 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Here's what I do on mine. It hooks NameplateDriverFrame:OnNamePlateCreated() when it creates nameplates and CompactUnitFrame_UpdateHealth() to update. I also store a mapping between the unitframe and the text to prevent collisions with other addons or future additions from Blizzard.
Lua Code:
  1. local NamePlateHealthText={};
  2. hooksecurefunc(NamePlateDriverFrame,"OnNamePlateCreated",function(self,base)--  Hook Nameplate creation
  3.     local unitframe=base.UnitFrame;
  4.  
  5.     local health=unitframe.healthBar:CreateFontString(nil,"OVERLAY");
  6.     health:SetFont("Fonts\\ArialN.ttf",10,"THICKOUTLINE");--    Fonts are easier to read when made from scratch rather than resizing an inherited one
  7.     health:SetPoint("LEFT");
  8.     health:SetTextColor(0,1,0);
  9.  
  10.     NamePlateHealthText[unitframe]=health;
  11. end);
  12.  
  13. hooksecurefunc("CompactUnitFrame_UpdateHealth",function(self)-- This is a shared function with other UnitFrames
  14.     if NamePlateHealthText[self] then NamePlateHealthText[self]:SetText(UnitHealth(self.displayedUnit)); end
  15. end);
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-01-19 at 08:51 AM.
  Reply With Quote