Call as
Conditions.spatial_stats.observation(cache, method, unit, power)
Record the dependency Conditions.spatial_stats.observation, 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 health or mana number for a PROXIMITY_* condition through the evaluation cache, protected against errors. With power set it passes Enum.PowerType.Mana as the second argument; restricted, negative, NaN or infinite readings are rejected.
Arguments
| Name | Type | What it does |
|---|---|---|
cache | table | nil | Evaluation-pass cache passed to getCached, or nil to read directly. |
method | function | API to call, such as UnitHealth or UnitPowerMax. |
unit | string | Unit token to read. |
power | boolean | nil | Truthy to read mana. |
Returns
| 1 | number | nil | The reading, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason for nil: missing-api, api-error, restricted-value or statistic-unavailable. |
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 | |||||
|---|---|---|---|---|---|
Enum.PowerType |
Secret values (Retail and Forever)
On Retail and Forever the game hands addons secret values. This helper checks what it reads (addon.Platform:CanReadValue) and returns nil with a reason such as restricted-value instead of a secret it cannot compare. Treat nil as unavailable, not as false.
How the addon calls it
Conditions.spatial_stats.statisticlocal current,reason=observation(cache,method,unit,mana)
Source
Conditions/spatial_stats.lua, line 60. Read only in game; Duplicate makes an editable copy.
Conditions.spatial_stats.observation(cache, method, unit, power)
if type(method)~="function" then return nil,"missing-api" end
local ok,current
if power then ok,current=pcall(addon.getCached,cache,method,unit,Enum.PowerType.Mana)
else ok,current=pcall(addon.getCached,cache,method,unit) end
if not ok then return nil,"api-error" end
if not addon.Platform:CanReadValue(current) then return nil,"restricted-value" end
if type(current)~="number" or current~=current or current<0 or current==math.huge then return nil,"statistic-unavailable" end
return current




