WoW:API UnitHealth: Difference between revisions

added info about 0 result for non existing target, corrected the example
(added info about 0 result for non existing target, corrected the example)
Line 4: Line 4:


==Parameters==
==Parameters==
===Arguments===
:;unit : [[UnitId]] - identifies the unit to query health for
:;unit : [[UnitId]] - the unit's health to query


===Returns===
==Returns==
:;health : Integer - current health of the specified unit.
:;health : Integer - current health of the specified unit, returns 0 if the specified unit does not exist (eg. "target" given but there is no target)


==Example==
==Example==
UnitHealth("target"); -- Note: we're assuming the target isn't a friendly player/pet in our group.
Print the target's health to the chat frame:
 
DEFAULT_CHAT_FRAME:AddMessage( "target health ="..UnitHealth("target") )
===Result===
Prints the player's and target's health to the chat frame.
Anonymous user