呼叫方式
addon.Platform:GetLossOfControlCount()
可直接透過 addon 使用,不需要相依項目。
作用
使用受保護的無參數點號呼叫,讀取有說明文件的活躍失去控制數量。要求結果可讀且為有限的非負整數。零表示一次完整的空掃描,不需要列 API。RM 將掃描限制為 256 列,超出該資源預算時傳回無法使用;這並不是原生宣告的最大值。所需觀測缺少、失敗、受限或格式錯誤時維持為無法使用。
參數
| 名稱 | 類型 | 作用 |
|---|---|---|
self | RMPlatform | Rotation Master 平台轉接器(使用冒號呼叫時隱含傳入)。 |
傳回值
| 1 | number | nil | 已知的活躍計數,範圍為零到 RM 的掃描預算;無法使用時為 nil。 |
|---|---|---|
| 2 | string | nil | 計數為 nil 時的戰鬥政策、功能、觀測或掃描預算原因。 |
版本
內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。
- 該版本無法使用(原因請見提示)
- 僅在暴雪的棄用相容層開啟時
| 遊戲 API | |||||
|---|---|---|---|---|---|
C_LossOfControl | |||||
canaccessvalue |
機密值(正式版與永久)
在正式版與永久上,遊戲交給插件的是機密值。此輔助函式會檢查它讀取的內容(addon.Platform:CanReadValue),遇到無法比較的機密值時,會傳回 nil 並附上原因(例如 restricted-value),而不是傳回該機密值。請將 nil 視為無法使用,而非假。
範例
local count = addon.Platform:GetLossOfControlCount()
if count == nil then return nil end
return count > 0原始碼
Platform/loss_of_control.lua,第 16 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。
Platform.loss_of_control.GetLossOfControlCount(self)
local policy=self:GetCombatDataPolicy()
if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
local namespace=C_LossOfControl
if not self:CanReadValue(namespace) then return nil,'restricted-value' end
if type(namespace)~='table' then return nil,'missing-api' end
local methodOk,method=pcall(function() return namespace.GetActiveLossOfControlDataCount end)
if not methodOk then return nil,'api-error' end
if not self:CanReadValue(method) then return nil,'restricted-value' end
if type(method)~='function' then return nil,'missing-api' end
local ok,count=pcall(method)
if not ok then return nil,'api-error' end
if not self:CanReadValue(count) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(count) then return nil,'restricted-value' end
if count==nil then return nil,'loss-of-control-count-unavailable' end
if type(count)~='number' or count~=count or count==math.huge or count==-math.huge or count<0 or count%1~=0 then return nil,'invalid-api-result' end
if count>256 then return nil,'loss-of-control-budget-exceeded' end
return count




