参考 › 函数参考 › Platform

Platform.spells.IsAutoRepeatActive

公共

调用方式

addon.Platform:IsAutoRepeatActive(spellID)

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

作用

读取玩家某个法术(例如射击或自动射击)的自动重复状态。这与当前或排队中的施法不同。现代客户端会收到确切的法术 ID;旧版查询会先解析玩家的法术书栏位。受限的客户端策略、无法读取的结果以及不可用的法术书栏位会返回 nil 及原因。这只观测状态,从不开始或停止法术。

参数

名称类型作用
selfRMPlatformRotation Master 平台适配器(使用冒号调用时隐含传入)。
spellIDnumber正整数法术 ID,而不是法术书栏位。

返回值

1boolean | nil客户端报告此法术正在自动重复时为 true;报告未激活时为 false;不可用时为 nil。
2string | nil结果为 nil 时的验证或可用性原因。

版本

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

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

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

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

示例

local shooting = addon.Platform:IsAutoRepeatActive(75) -- Auto Shot
if shooting == nil then return nil end
return not shooting

依赖项

源码

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

Platform.spells.IsAutoRepeatActive(self, spellID)
    local policy=self:GetCombatDataPolicy()
    if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
    local valid,reason=identifier(spellID,true)
    if not valid then return nil,reason end
    local native=C_Spell and C_Spell.IsAutoRepeatSpell
    local ok,active
    if type(native)=='function' then
        ok,active=pcall(native,spellID)
    else
        if type(IsAutoRepeatSpell)~='function' or type(FindSpellBookSlotBySpellID)~='function' then return nil,'missing-api' end
        local found,slot=pcall(FindSpellBookSlotBySpellID,spellID,false)
        if not found then return nil,'api-error' end
        if not self:CanReadValue(slot) then return nil,'restricted-value' end
        if slot==nil then return nil,'spell-not-in-book' end
        if type(slot)~='number' or slot<1 or slot==math.huge or slot%1~=0 then return nil,'invalid-api-result' end
        ok,active=pcall(IsAutoRepeatSpell,slot,BOOKTYPE_SPELL or 'spell')
    end
    if not ok then return nil,'api-error' end
    if not self:CanReadValue(active) then return nil,'restricted-value' end
    if type(native)~='function' then
        if active==0 then active=false elseif active==1 then active=true end
    end
    if type(active)~='boolean' then return nil,'invalid-api-result' end
    return active

返回函数参考