Quantcast WoWInterface - View Single Post - Help with an Addon Nameplate
View Single Post
11-01-19, 08:49 AM   #3
Ayacoz
A Murloc Raider
Join Date: Nov 2019
Posts: 4
Thanks mate

i'll run some tests to see if its what i want, but it seems to be.

I'll tell you the results

Originally Posted by SDPhantom View Post
Here's what I do on mine. It hooks NameplateDriverFrame:OnNamePlateCreated() when it creates nameplates and CompactUnitFrame_UpdateHealth(). 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);
  Reply With Quote