Llamar como
Conditions.spatial.booleanRead(cache, method, ...)
Registra la dependencia Conditions.spatial.booleanRead y luego llámala con ese nombre. Una llamada con espacio de nombres no pasa self: usa una llamada con dos puntos o pasa tú mismo el objeto.
Qué hace
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.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
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. |
Retornos
| 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. |
Ediciones
Las funciones auxiliares integradas se registran en todas las ediciones. Lo que cambia es la API del juego que leen; donde falta alguna, la función auxiliar recurre a una alternativa o devuelve nil con un motivo.
No lee directamente ninguna API del juego.
Valores secretos (Retail y Forever)
En Retail y Forever, el juego entrega a los addons valores secretos. Esta función auxiliar comprueba lo que lee (addon.Platform:CanReadValue) y, en lugar de un secreto que no puede comparar, devuelve nil con un motivo como restricted-value. Trata nil como no disponible, no como falso.
Cómo la llama el addon
- Recuento por distancia (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)
Dependencias
protectedRead→Conditions.spatial.protectedRead
Código fuente
Conditions/spatial.lua, línea 73. Solo lectura en el juego; Duplicar crea una copia editable.
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"