Llamar como
Conditions.spatial_stats.observation(cache, method, unit, power)
Registra la dependencia Conditions.spatial_stats.observation 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
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.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
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. |
Retornos
| 1 | number | nil | The reading, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason for nil: missing-api, api-error, restricted-value or statistic-unavailable. |
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 disponible en esa edición (el motivo aparece en la información emergente)
- Solo mientras estén activas las alternativas de Blizzard para API obsoletas
| API del juego | |||||
|---|---|---|---|---|---|
Enum.PowerType |
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
Conditions.spatial_stats.statisticlocal current,reason=observation(cache,method,unit,mana)
Código fuente
Conditions/spatial_stats.lua, línea 60. Solo lectura en el juego; Duplicar crea una copia editable.
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




