Referencia › Referencia de funciones › Conditions

Conditions.spatial_stats.statistic

dependencia

Llamar como

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

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

Argumentos

NombreTipoQué hace
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.

Retornos

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

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

Cómo la llama el addon

Dependencias

Código fuente

Conditions/spatial_stats.lua, línea 81. Solo lectura en el juego; Duplicar crea una copia editable.

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

Volver a Referencia de funciones