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!