Quantcast WoWInterface - View Single Post - Adding %HP to default nameplates; getting an error occasionally
View Single Post
03-30-18, 01:05 PM   #7
nKweo
A Deviate Faerie Dragon
 
nKweo's Avatar
Join Date: Oct 2012
Posts: 16
Brilliant, thanks! Seems to work smooth now. I 'borrowed' heavily from your code. Happy to hear if there are flaws here.
Code:
-- Add health percent text to (unprotected) nameplates (credit: nPlates by Grimsbain)
hooksecurefunc("CompactUnitFrame_UpdateStatusText", function(frame)
	if frame:IsForbidden() or ( UnitIsFriend("player",frame.displayedUnit) and not UnitIsUnit(frame.displayedUnit,"player") ) then return end
	if not frame.healthBar.percent then
		frame.healthBar.percent = frame.healthBar:CreateFontString(nil,"OVERLAY")
		frame.healthBar.percent:SetPoint("LEFT",frame.healthBar)
		frame.healthBar.percent:SetFont(STANDARD_TEXT_FONT,12,"OUTLINE")
	end
		local percentcalc = ceil((UnitHealth(frame.displayedUnit) / UnitHealthMax(frame.displayedUnit)) * 100)
		frame.healthBar.percent:SetFormattedText("%d%%",percentcalc)
--		frame.healthBar.percent:Show()
end)
EDIT: I'm trying to hide the display from friendly plates at all times (except the personal resource display). Doesn't seem to work like this. Suggestions appreciated!

Last edited by nKweo : 03-30-18 at 01:21 PM.
  Reply With Quote