Call as
Conditions.spatial.booleanRead(cache, method, ...)
Record the dependency Conditions.spatial.booleanRead, 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
Calls a yes/no game API through the evaluation cache, protected against errors, for the distance conditions. Accepts nil, false and 0 as no and true and 1 as yes; a missing API, an error, a restricted value or any other answer gives nil with a reason.
Arguments
| Name | Type | What it does |
|---|---|---|
cache | table | nil | Evaluation-pass cache passed to getCached, or nil to read directly. |
method | function | Game API to call, such as UnitExists or UnitIsEnemy. |
... | any | Arguments forwarded to method. |
Returns
| 1 | boolean | nil | The answer, or nil when it cannot be read. |
|---|---|---|
| 2 | string | nil | Reason for nil: missing-api, api-error, restricted-value or invalid-api-result. |
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.
It reads no game API directly.
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
- Distance Count (evaluate)
local present,issue=booleanRead(cache,UnitExists,entity.unit) Conditions.spatial.combatFilterlocal fighting,why=booleanRead(cache,UnitAffectingCombat,unit)Conditions.spatial.nameplateDistanceCountlocal present,issue=booleanRead(cache,UnitExists,unit)
Dependencies
protectedRead→Conditions.spatial.protectedRead
Source
Conditions/spatial.lua, line 73. Read only in game; Duplicate makes an editable copy.
Conditions.spatial.booleanRead(cache, method, ...)
local ok,result=protectedRead(cache,method,...)
if not ok then return nil,result=="missing-api" and result or "api-error" end
if not addon.Platform:CanReadValue(result) then return nil,"restricted-value" end
if result==nil or result==false or result==0 then return false end
if result==true or result==1 then return true end
return nil,"invalid-api-result"