All pastes #58929 Raw Edit

Mine

public text v1 · immutable
#58929 ·published 2006-05-26 00:06 UTC
rendered paste body
Here's what I use to stick target health percentage into my TargetFrame.  It's so little code I don't bother having an addon for it.

[pre]
local f = CreateFrame("Frame")
f.text = TargetDeadText
f.update = function(self) 
	local t = UnitHealth("target")
	if(t == 0) then t = DEAD
	else t = t/UnitHealthMax("target")*100 .. "%" end
	self.text:SetText(t)
end
f:RegisterEvent("UNIT_HEALTH")
f:RegisterEvent("PLAYER_TARGET_CHANGED")
f:SetScript("OnEvent",function()
	if(event == "PLAYER_TARGET_CHANGED" or (event == "UNIT_HEALTH" and arg1 == "target") and UnitExists("target")) then
		this:update()
	end
end)
TargetDeadText.Hide = function() end
TargetDeadText:Show()
[/pre]