WoW:API UnitHealth: Difference between revisions

m
Move page script moved page API UnitHealth to WoW:API UnitHealth without leaving a redirect
({{wowapi}}, update formatting, reword text)
m (Move page script moved page API UnitHealth to WoW:API UnitHealth without leaving a redirect)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{wowapi}} __NOTOC__
{{wowapi}} __NOTOC__
Returns the current health of the specified unit. Returns the exact hitpoints for friendly players and pets in your raid/party, percentages otherwise.
Returns the current health of the specified unit.
  local health = UnitHealth(unit);
  local health = UnitHealth(unit);


==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==
ChatFrame1:AddMessage('Player health: ' .. UnitHealth("player") .. " HP");
Print the target's health to the chat frame:
  ChatFrame1:AddMessage('Target health: ' .. UnitHealth("target") .. "%"); -- Note: we're assuming the target isn't a friendly player/pet in our group.
  DEFAULT_CHAT_FRAME:AddMessage( "target health ="..UnitHealth("target") )
 
===Result===
Prints the player's and target's health to the chat frame.
Anonymous user