WoW:API UnitHealth: Difference between revisions

m
Move page script moved page API UnitHealth to WoW:API UnitHealth without leaving a redirect
No edit summary
m (Move page script moved page API UnitHealth to WoW:API UnitHealth without leaving a redirect)
 
(7 intermediate revisions by 7 users not shown)
Line 1: Line 1:
<center>'''UnitHealth''' ''-Documentation by [[User:Danboo|danboo]]-''</center>
{{wowapi}} __NOTOC__
 
Returns the current health of the specified unit.
Returns the current health of the specified unit, in percentage, for:
 
*target
*mouseover
*pet if pet is charmed/enslaved
 
Otherwise in points.
 
  local health = UnitHealth(unit);
  local health = UnitHealth(unit);


----
==Parameters==
;''Arguments''
:;unit : [[UnitId]] - identifies the unit to query health for
 
:(String unit)
 
:;arg1 : the unit's health to query
 
----
;''Returns''
 
:health
:;health : the current health of the specified unit
 
----
;''Example''
local health = UnitHealth("player");
local health2 = UnitHealth("target");
ChatFrame1:AddMessage('player health: ' .. health);
ChatFrame1:AddMessage('target health: ' .. health .. "%");
 
;''Result''
Prints the player's and target's health to the chat frame as
'player health: 900' and 'target health: 80%'.
 
----
;''Description''


: Returns the current health of the specified unit. The health is returned in real points only if the unit is in the player's party. Otherwise, a percentage is returned (0-100). (Note, that the player, the player's pet, and any party member pets are considered to be in the party.)
==Returns==
:;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==
{{WoW API}}
Print the target's health to the chat frame:
DEFAULT_CHAT_FRAME:AddMessage( "target health ="..UnitHealth("target") )
Anonymous user