參考資料 › 函式參考 › Conditions

Conditions.spatial_stats.statistic

相依項目

呼叫方式

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

記錄相依項目 Conditions.spatial_stats.statistic,然後以該名稱呼叫。含命名空間的呼叫不會傳入 self:請使用冒號呼叫,或自行傳入該物件。

作用

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.

參數

名稱類型作用
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.

傳回值

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

版本

內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。

  • 該版本無法使用(原因請見提示)
  • 僅在暴雪的棄用相容層開啟時
遊戲 API經典時代TBC 週年版經典進程永久正式版
UnitHealth經典時代TBC 週年版經典進程永久正式版
UnitHealthMax經典時代TBC 週年版經典進程永久正式版
UnitPower經典時代TBC 週年版經典進程永久正式版
UnitPowerMax經典時代TBC 週年版經典進程永久正式版

插件如何呼叫它

相依項目

原始碼

Conditions/spatial_stats.lua,第 81 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。

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

返回函式參考