呼叫方式
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.
參數
| 名稱 | 類型 | 作用 |
|---|---|---|
cache | table | nil | Evaluation-pass cache passed to getCached, or nil to read directly. |
unit | string | Unit token to read. |
mana | boolean | True for mana, false for health. |
percentage | boolean | True to return current as a percentage (0 to 100) of the maximum. |
deficit | boolean | True, when percentage is false, to return the maximum minus current. |
傳回值
| 1 | number | nil | The requested reading, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason for nil from observation, or statistic-unavailable when the maximum is zero. |
版本
內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。
- 該版本無法使用(原因請見提示)
- 僅在暴雪的棄用相容層開啟時
插件如何呼叫它
- 範圍內的生命力 (evaluate)
local cur,why=statistic(c,unit,false,false,value.value<0) - 範圍內的生命力百分比 (evaluate)
local cur,why=statistic(c,unit,false,true,false) - 範圍內的生命力百分比計數 (evaluate)
local cur,why=statistic(c,unit,false,true,false) - 範圍內的生命力計數 (evaluate)
local cur,why=statistic(c,unit,false,false,value.health<0) - 範圍內的法力 (evaluate)
local cur,why=statistic(c,unit,true,false,value.value<0) - 範圍內的法力百分比 (evaluate)
local cur,why=statistic(c,unit,true,true,false) - 範圍內的法力百分比計數 (evaluate)
local cur,why=statistic(c,unit,true,true,false) - 範圍內的法力計數 (evaluate)
local cur,why=statistic(c,unit,true,false,value.mana<0)
相依項目
observation→Conditions.spatial_stats.observation
原始碼
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




