呼叫方式
addon.Platform:GetUnitPointFragmentObservation(unit, powerType, kind)
可直接透過 addon 使用,不需要相依項目。
作用
觀測用戶端以片段回報的點數資源(潘達利亞之謎的燃火餘燼)。目前值確切使用 UnitPower(unit,powerType,true),最大值確切使用 UnitPowerMax(unit,powerType,true);結果會除以暴雪的 MAX_POWER_PER_EMBER(10),因此 35 個片段為 3.5。僅限探測政策。缺少、失敗、受限或格式錯誤的資料維持為無法使用;絕不會退回完整單位的查詢。不新增快取。
參數
| 名稱 | 類型 | 作用 |
|---|---|---|
self | RMPlatform | Rotation Master 平台轉接器(使用冒號呼叫時隱含傳入)。 |
unit | string | 確切的非空單位代碼,原樣傳遞。 |
powerType | number | 明確、可讀、有限的非負整數能量選擇器。 |
kind | string | 確切為目前值(UnitPower)或最大值(UnitPowerMax)。 |
傳回值
| 1 | number | nil | 以完整單位表示並保留小數部分的有限數量;無法使用時為 nil。 |
|---|---|---|
| 2 | string | nil | 數量為 nil 時的政策、查詢驗證或所需觀測的可用性原因。 |
版本
內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。
- 該版本無法使用(原因請見提示)
- 僅在暴雪的棄用相容層開啟時
| 遊戲 API | |||||
|---|---|---|---|---|---|
UnitPower | |||||
UnitPowerMax | |||||
canaccessvalue |
機密值(正式版與永久)
在正式版與永久上,遊戲交給插件的是機密值。此輔助函式會檢查它讀取的內容(addon.Platform:CanReadValue),遇到無法比較的機密值時,會傳回 nil 並附上原因(例如 restricted-value),而不是傳回該機密值。請將 nil 視為無法使用,而非假。
範例
local embers = Enum.PowerType.BurningEmbers
if not embers then return nil end
local current = addon.Platform:GetUnitPointFragmentObservation("player", embers, "current")
if current == nil then return nil end
return current >= 3.5相依項目
pointFragmentsPerWhole(builtin:Platform/points.lua:pointFragmentsPerWhole)
原始碼
Platform/points.lua,第 162 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。
Platform.points.GetUnitPointFragmentObservation(self, unit, powerType, kind)
if self:GetCombatDataPolicy()~='probe' then return nil,'unsupported-policy' end
if not self:CanReadValue(unit) or not self:CanReadValue(powerType) or not self:CanReadValue(kind) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if type(powerType)~='number' or powerType~=powerType or powerType<0 or powerType==math.huge or powerType%1~=0 then return nil,'invalid-point-power-query' end
if kind~='current' and kind~='maximum' then return nil,'invalid-point-power-query' end
local api
if kind=='current' then api=UnitPower else api=UnitPowerMax end
if type(api)~='function' then return nil,'missing-api' end
local ok,result=pcall(api,unit,powerType,true)
if not ok then return nil,'api-error' end
if not self:CanReadValue(result) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(result) then return nil,'restricted-value' end
if result==nil then return nil,'point-power-unavailable' end
if type(result)~='number' or result~=result or result==math.huge or result==-math.huge then return nil,'invalid-api-result' end
return result/pointFragmentsPerWhole




