you also need to register an event for the tag like this
Code:
oUF.Tags["[customtag]"] = function(unit)
local m, n = UnitHealthMax(unit), UnitHealth(unit)
return m == 0 and 0 or n ~= m and string.format("-%s|r", (m - n)) or m == n and m
end
oUF.TagEvents["[customtag]"] = "UNIT_HEALTH UNIT_MAXHEALTH"
and to use it something like this
Code:
local hp = CreateFrame"StatusBar"
hp:SetHeight(20)
hp:SetStatusBarTexture(texture)
hp:SetPoint(top)
local hpp = hp:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
hpp:SetPoint("RIGHT", -2, 0)
hpp:SetTextColor(1, 1, 1)
self:Tag(hpp, "[customtag]")
hp.bg = hpbg
self.Health = hp