Referência › Referência de funções › Conditions

Conditions.spatial_stats.observation

dependência

Chame como

Conditions.spatial_stats.observation(cache, method, unit, power)

Registre a dependência Conditions.spatial_stats.observation e depois chame-a por esse nome. Uma chamada com namespace não passa self: use uma chamada com dois-pontos ou passe o objeto você mesmo.

O que faz

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

NomeTipoO que faz
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.

Edições

As funções auxiliares integradas são registradas em todas as edições. O que muda é a API do jogo que elas leem; quando uma está ausente, a função auxiliar recorre a uma alternativa ou retorna nil com um motivo.

  • Indisponível nessa edição (o motivo está na dica)
  • Só enquanto as alternativas da Blizzard para APIs obsoletas estiverem ativas
API do jogoClassic EraTBC AnniversaryClassic ProgressionForeverRetail
Enum.PowerTypeClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Valores secretos (Retail e Forever)

No Retail e no Forever, o jogo entrega valores secretos aos addons. Esta função auxiliar verifica o que lê (addon.Platform:CanReadValue) e retorna nil com um motivo como restricted-value em vez de um valor secreto que não consegue comparar. Trate nil como indisponível, não como false.

Como o addon a chama

Código-fonte

Conditions/spatial_stats.lua, linha 60. Somente leitura no jogo; Duplicar cria uma cópia editável.

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

Voltar para Referência de funções