Skip to content

unit_power

The unit_power function retrieves the current power value of a specified unit. This function is useful for monitoring the power resources (such as mana, energy, rage, etc.) of units.

Parameters

  • unit (string): The unit identifier (such as "player", "target", "focus", etc.) for which to retrieve the power value.
  • powerType (string or number, optional): The type of power to retrieve (such as "MANA", "ENERGY", "RAGE", etc.). If not specified, the default power type for the unit is used.

Returns

  • power (number): The current power value of the specified unit.

Example Usage in Lua

Here is an example of how to use the unit_power function in Lua:

local api = ...

-- Function to print the current power value of a specified unit
function PrintUnitPower(unit, powerType)
    local power = api.unit_power(unit, powerType)
    print("The unit '" .. unit .. "' has " .. power .. " " .. (powerType or "default power") .. ".")
end

-- Example usage: Print the current mana value of the player
PrintUnitPower("player", "MANA")