【问题标题】:Logitech Gaming Software sub profile scripting罗技游戏软件子配置文件脚本
【发布时间】:2019-11-26 16:39:15
【问题描述】:

G13 能够为活动的游戏配置文件设置三个不同的子配置文件,称为 M1、M2、M3 或 MKeystates...基本上允许我将三个命令映射到 G13 上的每个键,具体取决于哪个 Mkey 配置文件处于活动状态.

我希望脚本知道 G13 的当前 MKeystate M1、M2、M3 是什么,并在 M1、M2 或 M3 一次仅对一个 MKeyState 执行这些命令,而不是在每个 MKeyState 上执行这些命令。因此,如果子配置文件 1“M1”处于活动状态并且我按下 G4 键,LCD 会显示“前进”,如果子配置文件 2“M2”处于活动状态并且我按下相同的 G4 键,那么 LCD 会显示不同的内容,依此类推。

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

我尝试在第 27 行之后的部分中添加此内容,但出现语法错误

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

这是我的代码。我想要它,这样我就可以根据当前活动的子配置文件/ MKeyState 让相同的按键执行不同的操作。

isPressed = false;

function OnEvent(event, arg, family)
    -- If a G-Key is pressed
    if event =="G_PRESSED" then
        -- was it G9?
        if arg == 9 then
            ClearLCD ()
            OutputLCDMessage("Auto Run ON", 2000)
            ClearLCD () 
            -- If we're not currently running
            if not isPressed then
                -- we are now
                PressKey("w");
                isPressed = true
            else
            ClearLCD ()
            OutputLCDMessage("Auto Run OFF", 1000)
            ClearLCD ()
                -- stop running
                ReleaseKey("w");
                isPressed = false;
            end
        end
    end

    if ( arg == 4 ) then
            ClearLCD ()
            OutputLCDMessage("FOWARD")
    end

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

    if ( arg == 1 ) then
            ClearLCD ()
            OutputLCDMessage("PRIMARY WEAPON")
    end
end

【问题讨论】:

    标签: lua logitech-gaming-software


    【解决方案1】:

    很遗憾,您没有提供使用时收到的实际错误消息

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

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

    所以我假设 MKeyStatenil 并且 Lua 抱怨将数字与 nil 值进行比较。

    G 系列 Lua API 列出了以下示例

    示例

    -- Get the current M Key state`
    
    current_mkey = GetMKeyState()`
    

    【讨论】:

    • 对不起,如果我不清楚。请原谅我,因为这是我第一次尝试编写除 css 之外的任何东西。我在第 5 行遇到了语法错误。删除它清除了,现在据我所知这段代码有效,我只需要知道如何让它只适用于一个子配置文件,而不是所有子配置文件。
    【解决方案2】:

    这似乎有效

    
    -- Auto walk and Display Key Press
    isPressed = false
    
    function OnEvent(event, arg, family)
        if event == "G_PRESSED" then
            -- was it G9?
            if arg == 9 then
                ClearLCD()
                OutputLCDMessage("Auto Run ON", 2000)
                ClearLCD()
                -- If we're not currently running
                if not isPressed then
                    -- we are now
                    PressKey("w")
                    isPressed = true
                else
                    ClearLCD()
                    OutputLCDMessage("Auto Run OFF", 1000)
                    ClearLCD()
                    -- stop running
                    ReleaseKey("w")
                    isPressed = false
                end
            end
        end
    
        local MKeyState = GetMKeyState(family)
    
        if (arg == 4 and MKeyState == 1) then
            ClearLCD()
            OutputLCDMessage("FOWARD")
        end
    
        if (arg == 7 and MKeyState == 1) then
            ClearLCD()
            OutputLCDMessage("MOBI GLASS")
        end
    
        if (arg == 1 and MKeyState == 1) then
            ClearLCD()
            OutputLCDMessage("PRIMARY WEAPON")
        end
    end
    
    

    【讨论】:

    • GetMKeyState(family) 不应为 mouse 系列调用。最好把MKey状态检查放到if family == "lhc" then ... end
    猜你喜欢
    • 2021-07-28
    • 2021-07-05
    • 2021-11-02
    • 2020-04-23
    • 2021-08-14
    • 2021-11-12
    • 2021-08-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多