Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
mNo edit summary
No edit summary
Line 42: Line 42:
   
 
----
 
----
{{Template:WoW API}}
+
{{WoW API}}
[[Category:API Functions|UnitHealth]]
 
[[Category:API Unit Functions|UnitHealth]]
 

Revision as of 05:33, 4 January 2006

UnitHealth -Documentation by danboo-

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);

Arguments
(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.)

Template:WoW API