Lua 参数变为零

Lua 参数变为零,lua,Lua,好,, ingame时,我当前遇到以下错误: ...Addons\WatcherEx\GeminiSpellBook\GeminiSpellBook.lua:91: attempt to index local 'spell' (a nil value) stack trace: ...Addons\WatcherEx\GeminiSpellBook\GeminiSpellBook.lua:91: in function 'IsStance' ...Addons\WatcherE

好,, ingame时,我当前遇到以下错误:

...Addons\WatcherEx\GeminiSpellBook\GeminiSpellBook.lua:91: attempt to index local 'spell' (a nil value)
stack trace:
    ...Addons\WatcherEx\GeminiSpellBook\GeminiSpellBook.lua:91: in function 'IsStance'
    ...Addons\WatcherEx\GeminiSpellBook\GeminiSpellBook.lua:132: in function 'GetInnates'
    ...aming\NCSOFT\WildStar\Addons\WatcherEx\WatcherEx.lua:1868: in function 'UpdateSkillsList'
    ...aming\NCSOFT\WildStar\Addons\WatcherEx\WatcherEx.lua:1606: in function <...aming\NCSOFT\WildStar\Addons\WatcherEx\WatcherEx.lua:1600>
由以下函数调用:

-- Description: Gets all the Innate abilities for the current character being played and stores
--              them in the internal tInnates structure.
--              The function takes no arguments, but expects a 'self' parameter, so
--              should be called as SpellBook:GetInnates()
--
-- Parameters:
--
-- Returns:     The list of Innate abilities.
function GeminiSpellBook:GetInnates()
    if self.tInnates == nil or #self.tInnates <= 0 then
        self.tInnates = { }
        local tSpells = GameLib.GetClassInnateAbilitySpells().tSpells or { }

        for _,spell in ipairs(tSpells) do
            if spell ~= nil and not self.IsStance(spell) then
                table.insert(self.tInnates, spell)
            end
        end
    end

    return self.innates
end
--Description:获取当前角色的所有先天能力并存储
--它们在内部锡酸盐结构中。
--该函数不接受任何参数,但需要一个“self”参数,因此
--应称为拼写书:GetInnates()
--
--参数:
--
--返回:先天能力列表。
函数:GetInnates()

如果self.tInnates==nil或#self.tInnates您应该将调用从
self.IsStance(spell)
更改为
self:IsStance(spell)
或使用
self.IsStance(self,spell)
。由于您将
IsStance
定义为方法(使用
GeminiSpellBook:IsStance
),因此它将第一个参数设置为
self
,这是
spell
被分配的地方,而您期望的
spell
参数将获得
nil
值,这将导致您看到的错误。

非常感谢!对Lua来说还是个新手,但是这个解释在识别其他通话问题方面帮了我很大的忙!
-- Description: Gets all the Innate abilities for the current character being played and stores
--              them in the internal tInnates structure.
--              The function takes no arguments, but expects a 'self' parameter, so
--              should be called as SpellBook:GetInnates()
--
-- Parameters:
--
-- Returns:     The list of Innate abilities.
function GeminiSpellBook:GetInnates()
    if self.tInnates == nil or #self.tInnates <= 0 then
        self.tInnates = { }
        local tSpells = GameLib.GetClassInnateAbilitySpells().tSpells or { }

        for _,spell in ipairs(tSpells) do
            if spell ~= nil and not self.IsStance(spell) then
                table.insert(self.tInnates, spell)
            end
        end
    end

    return self.innates
end