Call as
Conditions.spatial_stats.statistic(cache, unit, mana, percentage, deficit)
Record the dependency Conditions.spatial_stats.statistic, then call it by that name. A namespaced call does not pass self: use a colon call or pass the object yourself.
What it does
Reads one unit's health or mana for the PROXIMITY_* conditions as an absolute value, a percentage of the maximum, or the deficit below the maximum.
Arguments
| Name | Type | What it does |
|---|---|---|
cache | table | nil | Evaluation-pass cache passed to getCached, or nil to read directly. |
unit | string | Unit token to read. |
mana | boolean | True for mana, false for health. |
percentage | boolean | True to return current as a percentage (0 to 100) of the maximum. |
deficit | boolean | True, when percentage is false, to return the maximum minus current. |
Returns
| 1 | number | nil | The requested reading, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason for nil from observation, or statistic-unavailable when the maximum is zero. |
Editions
Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.
- Not available on that edition (the reason is in the tooltip)
- Only while Blizzard's deprecation fallbacks are on
| Game API | |||||
|---|---|---|---|---|---|
UnitHealth | |||||
UnitHealthMax | |||||
UnitPower | |||||
UnitPowerMax |
How the addon calls it
- Health Within Range (evaluate)
local cur,why=statistic(c,unit,false,false,value.value<0) - Health Percentage Within Range (evaluate)
local cur,why=statistic(c,unit,false,true,false) - Health Percentage Count Within Range (evaluate)
local cur,why=statistic(c,unit,false,true,false) - Health Count Within Range (evaluate)
local cur,why=statistic(c,unit,false,false,value.health<0) - Mana Within Range (evaluate)
local cur,why=statistic(c,unit,true,false,value.value<0) - Mana Percentage Within Range (evaluate)
local cur,why=statistic(c,unit,true,true,false) - Mana Percentage Count Within Range (evaluate)
local cur,why=statistic(c,unit,true,true,false) - Mana Count Within Range (evaluate)
local cur,why=statistic(c,unit,true,false,value.mana<0)
Dependencies
observation→Conditions.spatial_stats.observation
Source
Conditions/spatial_stats.lua, line 81. Read only in game; Duplicate makes an editable copy.
Conditions.spatial_stats.statistic(cache, unit, mana, percentage, deficit)
local method=UnitHealth;if mana then method=UnitPower end
local current,reason=observation(cache,method,unit,mana)
if current==nil then return nil,reason end
if percentage or deficit then
local maximumMethod=UnitHealthMax;if mana then maximumMethod=UnitPowerMax end
local maximum,why=observation(cache,maximumMethod,unit,mana)
if maximum==nil then return nil,why end
if percentage then
if maximum==0 then return nil,"statistic-unavailable" end
local percent=current/maximum*100
if percent~=percent or percent==math.huge then return nil,"statistic-unavailable" end
return percent
end
return maximum-current
end
return current




