unit_cast_percent
The unit_cast_percent function calculates the percentage of a spell cast or channel completed for a specified unit. This function is useful for monitoring the progress of a unit's spell casting or channeling.
Parameters
unit(string): The unit identifier (such as "player", "target", "focus", etc.) for which to calculate the cast or channel percentage.
Returns
cast_percent_done(number): The percentage of the spell cast or channel completed. Returns 0 if the unit is not casting or channeling a spell.
Example Usage in Lua
Here is an example of how to use the unit_cast_percent function in Lua:
local api = ...
-- Function to print the cast or channel percentage of a specified unit
function PrintUnitCastPercent(unit)
local cast_percent_done = api.unit_cast_percent(unit)
print("The unit '" .. unit .. "' has completed " .. cast_percent_done .. "% of the current spell cast or channel.")
end
-- Example usage: Print the cast or channel percentage of the target unit
PrintUnitCastPercent("target")