WoW:API UnitHealth: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
({{wowapi}}, update formatting, reword text)
Line 1: Line 1:
<center>'''UnitHealth''' ''-Documentation by [[User:Danboo|danboo]]-''</center>
{{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, in percentage, for:
 
*target
*mouseover
*pet if pet is charmed/enslaved
 
Otherwise in points.
 
  local health = UnitHealth(unit);
  local health = UnitHealth(unit);


----
==Parameters==
;''Arguments''
===Arguments===
 
:;unit : [[UnitId]] - the unit's health to query
:(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: ' .. health2 .. "%");
 
;''Result''
Prints the player's and target's health to the chat frame as
'player health: 900' and 'target health: 80%'.


----
===Returns===
;''Description''
:;health : Integer - current health of the specified unit.


: Returns the current health of the specified unit. The health is returned in real points only if the unit is in the player's group (party or raid). Otherwise, a percentage is returned (0-100). (Note, that the player, the player's pet, and any group member pets are considered to be in the group.)
==Example==
ChatFrame1:AddMessage('Player health: ' .. UnitHealth("player") .. " HP");
ChatFrame1:AddMessage('Target health: ' .. UnitHealth("target") .. "%"); -- Note: we're assuming the target isn't a friendly player/pet in our group.


----
===Result===
{{WoW API}}
Prints the player's and target's health to the chat frame.

Revision as of 15:43, 23 December 2006

WoW API < UnitHealth

Returns the current health of the specified unit. Returns the exact hitpoints for friendly players and pets in your raid/party, percentages otherwise.

local health = UnitHealth(unit);

Parameters

Arguments

unit
UnitId - the unit's health to query

Returns

health
Integer - current health of the specified unit.

Example

ChatFrame1:AddMessage('Player health: ' .. UnitHealth("player") .. " HP");
ChatFrame1:AddMessage('Target health: ' .. UnitHealth("target") .. "%"); -- Note: we're assuming the target isn't a friendly player/pet in our group.

Result

Prints the player's and target's health to the chat frame.