Quantcast
Simple Nameplate Addon help needed - WoWInterface
Thread Tools Display Modes
10-07-20, 11:35 AM   #1
Ayacoz
A Murloc Raider
Join Date: Nov 2019
Posts: 5
Simple Nameplate Addon help needed

Hi there, i need some advice/help about an addon that i use.

Someone here in the forums did the code for me

local NamePlateHealthText={};
hooksecurefunc(NamePlateDriverFrame,"OnNamePlateCreated",function(self,base)-- Hook Nameplate creation
local unitframe=base.UnitFrame;

local health=unitframe.healthBar:CreateFontString(nil,"OVERLAY");
health:SetFont("Fonts\\FRIZQT__.TTF",12,"OUTLINE");-- Fonts are easier to read when made from scratch rather than resizing an inherited one
health:SetPoint("CENTER");
health:SetTextColor(1,1,1);

NamePlateHealthText[unitframe]=health;
end);

hooksecurefunc("CompactUnitFrame_UpdateHealth",function(self)-- This is a shared function with other UnitFrames
if NamePlateHealthText[self] then
local cur,max=UnitHealth(self.displayedUnit),UnitHealthMax(self.displayedUnit);
NamePlateHealthText[self]:SetFormattedText("%d - %.0f%%",cur,100*cur/max); end
end);


It works great for BfA, but ion Shadowlands, it doesnt, can anyone help me out ?

  Reply With Quote
04-22-21, 05:25 AM   #2
L3n1n
A Deviate Faerie Dragon
 
L3n1n's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 10
I know this is necroposting but i wrote solution for you:

Code:
hooksecurefunc("CompactUnitFrame_UpdateStatusText", function(frame)
	if frame:IsForbidden() then return end
	if frame.statusText then return end

	if not frame.healthBar.value then
		frame.healthBar.value = frame.healthBar:CreateFontString("$parentHeathValue", "OVERLAY")
		frame.healthBar.value:SetPoint("CENTER", frame.healthBar)
		frame.healthBar.value:SetFont('Fonts\\FRIZQT__.ttf', 12, "OUTLINE")
	end

	local cur, max = UnitHealth(frame.displayedUnit), UnitHealthMax(frame.displayedUnit)
	if cur > 0 then
		frame.healthBar.value:SetFormattedText("%d - %.0f%%", cur, 100*cur/max)
	else
		frame.healthBar.value:SetText("")
	end
end)

Last edited by L3n1n : 04-22-21 at 05:29 AM.
  Reply With Quote

WoWInterface » PTR » PTR General Discussion » Simple Nameplate Addon help needed

Thread Tools
Display Modes

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