Reference › Function reference › Conditions

Conditions.spatial.booleanRead

dependency

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

NameTypeWhat it does
cachetable | nilEvaluation-pass cache passed to getCached, or nil to read directly.
methodfunctionGame API to call, such as UnitExists or UnitIsEnemy.
...anyArguments forwarded to method.

Returns

1boolean | nilThe answer, or nil when it cannot be read.
2string | nilReason 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

Dependencies

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"

Back to Function reference