呼叫方式
addon.Platform:GetLossOfControlEvent(index, kind)
可直接透過 addon 使用,不需要相依項目。
作用
依原生索引與所請求的主題種類,讀取一條有說明文件的活躍失去控制記錄列。type 查詢只需要可讀的控制類型字串;school 查詢只需要可讀的有限非負整數法術類型遮罩。選擇性的計時以有限的 timeRemaining 或逐欄位的明確原因傳回,因此不相關的主題不需要可用的計時器。缺少的列是無法使用的快照觀測。不會使用顯示欄位、推斷的截止時間、持續時間總和、最大值或原生別名備用方案。
參數
| 名稱 | 類型 | 作用 |
|---|---|---|
self | RMPlatform | Rotation Master 平台轉接器(使用冒號呼叫時隱含傳入)。 |
index | number | 在 RM 256 列掃描預算內、從 1 開始的原生整數活躍列索引。 |
kind | string | 只能是 type 或 school;選擇所需的主題欄位,而不要求另一個。 |
傳回值
| 1 | table | nil | 標準化的所請求主題,包含有限的 timeRemaining 或 timeRemainingReason;所需的列或主題無法使用時為 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
if count == 0 then return false end
local row = addon.Platform:GetLossOfControlEvent(1, "type")
if not row then return nil end
return row.locType == "STUN"原始碼
Platform/loss_of_control.lua,第 45 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。
Platform.loss_of_control.GetLossOfControlEvent(self, index, kind)
local policy=self:GetCombatDataPolicy()
if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
if not self:CanReadValue(index) or not self:CanReadValue(kind) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(index) then return nil,'restricted-value' end
if type(index)~='number' or index~=index or index==math.huge or index==-math.huge or index<1 or index%1~=0 then return nil,'invalid-loss-of-control-query' end
if kind~='type' and kind~='school' then return nil,'invalid-loss-of-control-query' end
if index>256 then return nil,'loss-of-control-budget-exceeded' 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.GetActiveLossOfControlData 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,event=pcall(method,index)
if not ok then return nil,'api-error' end
if not self:CanReadValue(event) then return nil,'restricted-value' end
if event==nil then return nil,'loss-of-control-event-unavailable' end
if type(event)~='table' then return nil,'invalid-api-result' end
local subjectOk,subject=pcall(function() return event[kind=='type' and 'locType' or 'lockoutSchool'] end)
if not subjectOk then return nil,'api-error' end
if not self:CanReadValue(subject) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(subject) then return nil,'restricted-value' end
if subject==nil then return nil,'loss-of-control-subject-unavailable' end
local record={}
if kind=='type' then
if type(subject)~='string' then return nil,'invalid-api-result' end
record.locType=subject
else
if type(subject)~='number' or subject~=subject or subject==math.huge or subject==-math.huge or subject<0 or subject%1~=0 then return nil,'invalid-api-result' end
record.lockoutSchool=subject
end
local timeOk,remaining=pcall(function() return event.timeRemaining end)
if not timeOk then record.timeRemainingReason='api-error'
elseif not self:CanReadValue(remaining) then record.timeRemainingReason='restricted-value'
elseif canaccessvalue and not canaccessvalue(remaining) then record.timeRemainingReason='restricted-value'
elseif remaining==nil then record.timeRemainingReason='loss-of-control-time-unavailable'
elseif type(remaining)~='number' or remaining~=remaining or remaining==math.huge or remaining==-math.huge then record.timeRemainingReason='invalid-api-result'
else record.timeRemaining=remaining end
return record




