调用方式
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




