参考 › 函数参考 › Platform

Platform.runes.GetRuneCooldownObservation

公共

调用方式

addon.Platform:GetRuneCooldownObservation(index)

可直接通过 addon 使用,无需依赖项。

作用

为一个确切的原生栏位读取一次受保护的 GetRuneCooldown 元组。分别规范化 ready、start 和 duration:ready 需要可读的布尔值,而每个时间值需要可读的有限数字,并保留带符号、小数和零值。每个不可用的字段都附带其自己的原因。成功返回空元组时会产生部分记录;缺少能力、策略或原生调用失败时返回 nil。绝不从计时推断 ready,也不从 ready 推断计时。请在调用方缓存这份完整记录,以便在符文计数和冷却判断之间共享一次观测。

参数

名称类型作用
selfRMPlatformRotation Master 平台适配器(使用冒号调用时隐含传入)。
indexnumber确切的整数原生符文栏位,范围为 1 到 6。

返回值

1table | nil部分记录,包含 ready 或 readyReason、start 或 startReason,以及 duration 或 durationReason;仅当查询本身不可用时为 nil。
2string | nil记录为 nil 时的策略、栏位验证、能力或原生调用的可用性原因。

版本

内置辅助函数在每个版本上都会注册。不同的是它们读取的游戏 API;某个 API 缺失时,辅助函数会改用后备方案,或返回 nil 并附上原因。

  • 该版本不可用(原因见提示)
  • 仅在暴雪的弃用兼容层开启时
游戏 API经典旧世TBC 周年版经典进阶服永久服正式服
GetRuneCooldown经典旧世TBC 周年版经典进阶服永久服正式服

秘密值(正式服和永久服)

在正式服和永久服上,游戏交给插件的是秘密值。此辅助函数会检查它读取的内容(addon.Platform:CanReadValue),遇到无法比较的秘密值时返回 nil 并附上原因(例如 restricted-value),而不是返回该秘密值。请将 nil 视为不可用,而不是假。

示例

local rune = addon.Platform:GetRuneCooldownObservation(1)
if not rune or rune.ready == nil then return nil end
return rune.ready

依赖项

源码

Platform/runes.lua,第 72 行。在游戏中为只读;“复制”会生成一份可编辑的副本。

Platform.runes.GetRuneCooldownObservation(self, index)
    local policy=self:GetCombatDataPolicy()
    if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
    local valid,reason=validIndex(self,index)
    if not valid then return nil,reason end
    local api=GetRuneCooldown
    if type(api)~='function' then return nil,'missing-api' end
    local ok,tuple=pcall(function() return {api(index)} end)
    if not ok then return nil,'api-error' end
    local record={}
    record.start,record.startReason=numberField(self,tuple[1],'rune-start-unavailable')
    record.duration,record.durationReason=numberField(self,tuple[2],'rune-duration-unavailable')
    local ready=tuple[3]
    if not self:CanReadValue(ready) then record.readyReason='restricted-value'
    elseif ready==nil then record.readyReason='rune-ready-unavailable'
    elseif type(ready)~='boolean' then record.readyReason='invalid-api-result'
    else record.ready=ready end
    return record

返回函数参考