Référence › Référence des fonctions › Conditions

Conditions.spatial_stats.statistic

dépendance

Appel

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

Enregistrez la dépendance Conditions.spatial_stats.statistic, puis appelez-la sous ce nom. Un appel par espace de noms ne transmet pas self : utilisez un appel avec deux-points ou passez l'objet vous-même.

Ce qu'elle fait

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.

Arguments

NomTypeCe qu'elle fait
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.

Retours

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

Éditions

Les fonctions utilitaires intégrées sont enregistrées sur toutes les éditions. Ce qui diffère, c'est l'API du jeu qu'elles lisent ; quand l'une manque, la fonction utilitaire se rabat sur une alternative ou renvoie nil avec une raison.

  • Indisponible sur cette édition (la raison figure dans l'infobulle)
  • Uniquement tant que les solutions de repli de Blizzard pour les fonctions obsolètes sont actives
API du jeuClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitHealthClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitHealthMaxClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitPowerClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitPowerMaxClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Comment l'addon l'appelle

Dépendances

Source

Conditions/spatial_stats.lua, ligne 81. En lecture seule dans le jeu ; Dupliquer crée une copie modifiable.

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

Retour à Référence des fonctions