Logitech Gaming Software 子配置文件脚本

G13 能够设置三个名为 M1、M2、M3 或 MKeystates 的不同子配置文件,用于活动游戏配置文件...基本上允许我根据激活的 Mkey 配置文件将三个命令映射到 G13 上的每个按键,具体取决于哪个 Mkey 配置文件正在活动。

我想让脚本知道 G13 的当前 MKeystate M1、M2、M3 是什么,并且仅在一个 MKeyState(M1、M2 或 M3)上执行这些命令,而不是跨越每个文件。因此,如果子配置文件 1 " M1" 处于活动状态并且我按下 G4 键,则 LCD 显示 "前进",如果子配置文件 2 " M2" 处于活动状态并且我按下相同的 G4 键,则 LCD 将显示不同的东西,依此类推。

是否可以为每个子配置文件独立编写脚本?

我尝试在第 27 行后的部分中添加这个,但是我会得到一个语法错误

if ( arg == 4 and MKeyState == 1) then

这是我的代码。我希望能够根据当前活动的子配置文件/MKeyState 使相同的按键按下执行不同的操作。

IsnPressed = false;

function OnEvent(event, arg, family)
    -- 如果按下了 G 键
    if event =="G_PRESSED" then
        -- 是 G9 吗?
        if arg == 9 then
            ClearLCD ()
            OutputLCDMessage("自动运行 ON", 2000)
            ClearLCD ()
            -- 如果我们当前没有在运行
            if not IsPressed 那么
                – 现在我们在运行
                PressKey("w")
                IsPressed = true
            else
            ClearLCD ()
            OutputLCDMessage("自动 Run OFF", 1000)
            ClearLCD ()
                -- 停止运行
                ReleaseKey("w")
                IsPressed = false;
            end
        end
    end

    if ( arg == 4 ) then
            ClearLCD ()
            OutputLCDMessage("向前")
    end

    if ( arg == 7 ) then
            ClearLCD ()
            OutputLCDMessage("MOBI GLASS")
    end

    if ( arg == 1 ) then
            ClearLCD ()
            OutputLCDMessage("主武器")
    end
end
点赞
用户2858170
用户2858170

很遗憾,您没有提供使用下面代码时实际出现的错误信息:

if ( arg == 4 and MKeyState == 1) then

并且您也没有提供您实际尝试使用 M 键状态的完整代码。

因此我推测 MKeyStatenil,Lua 因比较数字和 nil 值而产生了错误。

G-Series Lua API 列出了以下示例:

示例

-- 获取当前的 M 键状态

current_mkey = GetMKeyState()
2019-11-26 07:48:17
用户12435288
用户12435288

这好像正在运行


-- 自动行走和显示按键按下
isPressed = false

function OnEvent(event, arg, family)
    if event == "G_PRESSED" then
        -- 判断是否是G9?
        if arg == 9 then
            ClearLCD()
            OutputLCDMessage("自动行走开", 2000)
            ClearLCD()
            -- 如果此时没有正在运行
            if not isPressed then
                -- 那现在开始运行
                PressKey("w")
                isPressed = true
            else
                ClearLCD()
                OutputLCDMessage("自动行走关", 1000)
                ClearLCD()
                -- 停止运行
                ReleaseKey("w")
                isPressed = false
            end
        end
    end

    local MKeyState = GetMKeyState(family)

    if (arg == 4 and MKeyState == 1) then
        ClearLCD()
        OutputLCDMessage("前进")
    end

    if (arg == 7 and MKeyState == 1) then
        ClearLCD()
        OutputLCDMessage("移动玻璃")
    end

    if (arg == 1 and MKeyState == 1) then
        ClearLCD()
        OutputLCDMessage("主武器")
    end
end
2019-11-26 08:39:15