LUA脚本,有人能帮忙吗?条件语句问题

function recoil_mode()
    if IsKeyLockOn(mode_switch_key) then
        if mode_switch then
            if IsKeyLockOn(full_mode_key) and full_mode then
                return "fullof4x"
            else
                return "quadruple"
            end
        end
    end
    if not IsKeyLockOn(mode_switch_key) then
        if not mode_switch then
            if IsKeyLockOn(full_mode_key) and full_mode then
                return "full"
            else
                return "basic"
            end
        end
    end
end

这是一个条件判断的代码,用于检查按键是否按下。 我的最大问题是“mode_switch”部分,它是一个布尔型变量,是本地变量。 如果mode_switch = True,那么意味着用户可以切换模式。

现在,当我通过另一个函数运行这段代码时,

function recoil_value(_weapon,_duration)
    local _mode = recoil_mode()
    local step = (math.floor(_duration/recoil_table[_weapon]["speed"])) + 1
    if step > #recoil_table[_weapon][_mode] then
        step = #recoil_table[_weapon][_mode]
    end

我遇到了一个错误; [string "LuaVM"]:560: attempt to get length of field '?' (a nil value)

请问有人知道发生了什么吗?

点赞