【问题标题】:Assigning Lua Script to a Button - Logitech G500s将 Lua 脚本分配给按钮 - Logitech G500s
【发布时间】:2014-10-30 22:09:45
【问题描述】:

我的罗技 G500 有一个小宏 - 我在 FPS 游戏中使用它来减少后坐力。请参阅下面的脚本:

EnablePrimaryMouseButtonEvents(true)
function OnEvent(event, arg)
    if event == "MOUSE_BUTTON_PRESSED" and arg == 1  then
        repeat
            MoveMouseRelative(-1,2)
            Sleep(16)
        until not IsMouseButtonPressed(1)
    end
end

问题是这个脚本一直在工作。 我希望按下另一个按钮 1 开始在按钮 2 上使用脚本并重新按下按钮 1 以中断脚本

我试图设置以下标志:

unction OnEvent(event, arg)
    if event == "MOUSE_BUTTON_PRESSED" and arg == 6 then --set flag for mb1
                mb1_pressed = true
        elseif event == "MOUSE_BUTTON_RELEASED" and arg == 6 then --set flag for mb1=false
        mb1_pressed = false
        end 

If mb1_pressed then
    if event == "MOUSE_BUTTON_PRESSED" and arg == 1 and  then
        repeat
            MoveMouseRelative(-1,2)
            Sleep(16)
        until not IsMouseButtonPressed(1)
    end

end  

但它不起作用。你能帮帮我吗?

【问题讨论】:

标签: lua lua-scripting-library logitech-gaming-software


【解决方案1】:
 if event == "MOUSE_BUTTON_PRESSED" and arg == 6 then --set flag for mb1
            mb1_pressed = true
 elseif event == "MOUSE_BUTTON_RELEASED" and arg == 6 then --set flag for mb1=false
    mb1_pressed = false
 end

这将在按下鼠标按钮时设置mb1_pressed,并在松开鼠标按钮时取消设置。因此,该变量仅在按下按钮时为真。

如果您想在每次按下时切换 mb1_pressed 值,您可以执行类似的操作

if event == "MOUSE_BUTTON_PRESSED" and arg == 6 then --toggle flag for mb1
            mb1_pressed = not mb1_pressed
end

【讨论】:

    猜你喜欢
    • 2021-11-02
    • 1970-01-01
    • 2023-01-03
    • 2021-09-12
    • 2020-03-12
    • 2019-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多