Riferimento › Riferimento delle funzioni › Conditions

Conditions.spatial_stats.observation

dipendenza

Chiamala come

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

Registra la dipendenza Conditions.spatial_stats.observation, poi chiamala con quel nome. Una chiamata con spazio dei nomi non passa self: usa una chiamata con i due punti o passa tu l'oggetto.

Cosa fa

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.

Argomenti

NomeTipoCosa fa
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.

Valori restituiti

1number | nilThe reading, or nil when unavailable.
2string | nilReason for nil: missing-api, api-error, restricted-value or statistic-unavailable.

Edizioni

Le funzioni di supporto integrate sono registrate su ogni edizione. Ciò che cambia è l'API di gioco che leggono; dove ne manca una, la funzione di supporto ripiega su un'alternativa o restituisce nil con un motivo.

  • Non disponibile su quell'edizione (il motivo è nel suggerimento)
  • Solo mentre sono attivi i ripieghi di Blizzard per le API deprecate
API di giocoClassic EraTBC AnniversaryClassic progressionForeverRetail
Enum.PowerTypeClassic EraTBC AnniversaryClassic progressionForeverRetail

Valori segreti (Retail e Forever)

Su Retail e Forever il gioco fornisce agli addon valori segreti. Questa funzione di supporto controlla ciò che legge (addon.Platform:CanReadValue) e restituisce nil con un motivo come restricted-value invece di un valore segreto che non può confrontare. Considera nil come non disponibile, non come false.

Come la chiama l'addon

Sorgente

Conditions/spatial_stats.lua, riga 60. Nel gioco è in sola lettura; Duplica crea una copia modificabile.

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

Torna a Riferimento delle funzioni