Referencia › Referencia de funciones › Conditions

Conditions.spatial_stats.observation

dependencia

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

NombreTipoQué hace
cachetable | nilEvaluation-pass cache passed to getCached, or nil to read directly.
methodfunctionAPI to call, such as UnitHealth or UnitPowerMax.
unitstringUnit token to read.
powerboolean | nilTruthy to read mana.

Retornos

1number | nilThe reading, or nil when unavailable.
2string | nilReason 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 juegoClassic EraTBC AnniversaryClassic ProgressionForeverRetail
Enum.PowerTypeClassic EraTBC AnniversaryClassic ProgressionForeverRetail

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

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

Volver a Referencia de funciones