unit_health_percent
The unit_health_percent function calculates the health percentage of a specified unit. This function is useful for monitoring the health status of units.
Parameters
unit(string): The unit identifier (such as "player", "target", "focus", etc.) for which to calculate the health percentage.
Returns
health_percent(number): The health percentage of the specified unit. Returns 0 if the unit does not exist.
Example Usage in Lua
Here is an example of how to use the unit_health_percent function in Lua:
local api = ...
-- Function to print the health percentage of a specified unit
function PrintUnitHealthPercent(unit)
local health_percent = api.unit_health_percent(unit)
print("The unit '" .. unit .. "' has " .. health_percent .. "% health.")
end
-- Example usage: Print the health percentage of the target unit
PrintUnitHealthPercent("target")