Riferimento › Riferimento delle funzioni › Conditions

Conditions.spatial_stats.statistic

dipendenza

Chiamala come

Conditions.spatial_stats.statistic(cache, unit, mana, percentage, deficit)

Registra la dipendenza Conditions.spatial_stats.statistic, 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 unit's health or mana for the PROXIMITY_* conditions as an absolute value, a percentage of the maximum, or the deficit below the maximum.

Argomenti

NomeTipoCosa fa
cachetable | nilEvaluation-pass cache passed to getCached, or nil to read directly.
unitstringUnit token to read.
manabooleanTrue for mana, false for health.
percentagebooleanTrue to return current as a percentage (0 to 100) of the maximum.
deficitbooleanTrue, when percentage is false, to return the maximum minus current.

Valori restituiti

1number | nilThe requested reading, or nil when unavailable.
2string | nilReason for nil from observation, or statistic-unavailable when the maximum is zero.

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
UnitHealthClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitHealthMaxClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitPowerClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitPowerMaxClassic EraTBC AnniversaryClassic progressionForeverRetail

Come la chiama l'addon

Dipendenze

Sorgente

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

Conditions.spatial_stats.statistic(cache, unit, mana, percentage, deficit)
    local method=UnitHealth;if mana then method=UnitPower end
    local current,reason=observation(cache,method,unit,mana)
    if current==nil then return nil,reason end
    if percentage or deficit then
        local maximumMethod=UnitHealthMax;if mana then maximumMethod=UnitPowerMax end
        local maximum,why=observation(cache,maximumMethod,unit,mana)
        if maximum==nil then return nil,why end
        if percentage then
            if maximum==0 then return nil,"statistic-unavailable" end
            local percent=current/maximum*100
            if percent~=percent or percent==math.huge then return nil,"statistic-unavailable" end
            return percent
        end
        return maximum-current
    end
    return current

Torna a Riferimento delle funzioni