WoW:API UnitHealth: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
 
m (Move page script moved page API UnitHealth to API UnitHealth without leaving a redirect)
 
(12 intermediate revisions by 12 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, in points, of the specified unit.
 
  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");
ChatFrame1:AddMessage('player health: ' .. health);
 
;''Result''
Prints the player's health to the chat frame as 'player health: 90'.
 
----
;''Description''


: Returns the current health, in points, of the specified unit.
==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==
{{Template:WoW API}}
Print the target's health to the chat frame:
DEFAULT_CHAT_FRAME:AddMessage( "target health ="..UnitHealth("target") )

Latest revision as of 04:47, 15 August 2023

WoW API < UnitHealth

Returns the current health of the specified unit.

local health = UnitHealth(unit);

Parameters[edit]

unit
UnitId - identifies the unit to query health for

Returns[edit]

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[edit]

Print the target's health to the chat frame:

DEFAULT_CHAT_FRAME:AddMessage( "target health ="..UnitHealth("target") )