呼叫方式
addon:GetConditionPointResource(unit, cache)
可直接透過 addon 使用,不需要相依項目。
作用
使用即時的職業到資源對應與 ComboPoints 備用,解析所選單位的點數資源選擇器。已知不存在時傳回 false;所需的身分或選擇器資料無法使用時傳回 nil 及原因。在評估輪次內共用完整的身分觀測。只有成功的玩家職業觀測會保留在目前的長期快取中,並與原生 UnitClass 身分綁定;存在性在每個輪次都會更新。這只選擇資源,不讀取其目前值或最大值。
參數
| 名稱 | 類型 | 作用 |
|---|---|---|
self | RMAddon | Rotation Master 插件實例(使用冒號呼叫時隱含傳入)。 |
unit | string | 確切的所選單位代碼;只有玩家職業可以使用成功的長期快取。 |
cache | table | nil | 評估輪次快取;為 nil 時直接觀測身分。資源對應在每次呼叫時即時解析。 |
傳回值
| 1 | number | boolean | nil | 明確的非負整數能量選擇器;已知單位不存在時為 false,所需資料無法使用時為 nil。 |
|---|---|---|
| 2 | string | nil | 選擇器為 nil 時的政策、查詢驗證或身分/選擇器可用性原因。 |
版本
內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。
- 該版本無法使用(原因請見提示)
- 僅在暴雪的棄用相容層開啟時
| 遊戲 API | |||||
|---|---|---|---|---|---|
Enum |
機密值(正式版與永久)
在正式版與永久上,遊戲交給插件的是機密值。此輔助函式會檢查它讀取的內容(addon.Platform:CanReadValue),遇到無法比較的機密值時,會傳回 nil 並附上原因(例如 restricted-value),而不是傳回該機密值。請將 nil 視為無法使用,而非假。
範例
local power, reason = addon:GetConditionPointResource("player", cache)
if power == nil then return nil, reason end
if power == false then return false end
return UnitPower("player", power) >= 4相依項目
playerClassCacheKey(builtin:Core/point_conditions.lua:playerClassCacheKey)pointIdentity→Core.point_conditions.pointIdentity
原始碼
Core/point_conditions.lua,第 58 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。
Core.point_conditions.GetConditionPointResource(self, unit, cache)
local platform=self.Platform
if platform:GetCombatDataPolicy()~='probe' then return nil,'unsupported-policy' end
if not platform:CanReadValue(unit) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
local record,reason=addon.Functions.cache.getCached(cache,pointIdentity,self,unit,playerClassCacheKey)
if not record then return nil,reason end
if not record.exists then return false end
local points=self.points
if not platform:CanReadValue(points) then return nil,'restricted-value' end
if type(points)~='table' then return nil,'invalid-point-resource-map' end
local ok,selected=pcall(function() return points[record.class] end)
if not ok then return nil,'api-error' end
if not platform:CanReadValue(selected) then return nil,'restricted-value' end
if selected==nil or selected==false then
local enum=Enum
if not platform:CanReadValue(enum) then return nil,'restricted-value' end
if type(enum)~='table' then return nil,'point-resource-unavailable' end
local typesOK,types=pcall(function() return enum.PowerType end)
if not typesOK then return nil,'api-error' end
if not platform:CanReadValue(types) then return nil,'restricted-value' end
if type(types)~='table' then return nil,'point-resource-unavailable' end
local fallbackOK,fallback=pcall(function() return types.ComboPoints end)
if not fallbackOK then return nil,'api-error' end
selected=fallback
if not platform:CanReadValue(selected) then return nil,'restricted-value' end
end
if selected==nil then return nil,'point-resource-unavailable' end
if type(selected)~='number' or selected~=selected or selected<0 or selected==math.huge or selected%1~=0 then return nil,'invalid-point-resource' end
return selected




