参考 › 函数参考 › Platform

Platform.actions.findSlot

依赖项

调用方式

Platform.actions.findSlot(id, bank)

记录依赖项 Platform.actions.findSlot,然后按该名称调用。带命名空间的调用不会传入 self:请使用冒号调用,或自行传入该对象。

作用

Finds the spell-book slot of a spell with FindSpellBookSlotBySpellID. bank "pet" searches the pet book, "any" searches the player book and then the pet book, and any other value searches the player book only. Returns the slot and its book type, or nil, nil and a reason: spell-not-in-book, invalid-api-result, or a reason from call (missing-api, api-error, restricted-value).

参数

名称类型作用
idnumberSpell ID to locate; not validated here (callers check it with spellID first).
bankstringSpell-book scope: spell, pet or any.

返回值

1number | nilPositive integer spell-book slot, or nil when not found or unavailable.
2string | nilBook type for that slot: BOOKTYPE_PET (pet) or BOOKTYPE_SPELL (spell); nil on failure.
3string | nilReason when the slot is nil.

版本

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

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

插件如何调用它

依赖项

源码

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

Platform.actions.findSlot(id, bank)
    local pet=bank=="pet"
    local slot,reason=call(FindSpellBookSlotBySpellID,id,pet)
    if reason then return nil,nil,reason end
    if slot==nil and bank=="any" then
        pet=true;slot,reason=call(FindSpellBookSlotBySpellID,id,true)
        if reason then return nil,nil,reason end
    end
    if slot==nil then return nil,nil,"spell-not-in-book" end
    if type(slot)~="number" or slot<1 or slot==math.huge or slot%1~=0 then return nil,nil,"invalid-api-result" end
    return slot,pet and (BOOKTYPE_PET or "pet") or (BOOKTYPE_SPELL or "spell")

返回函数参考