将Lua脚本分配给按钮 - 罗技G500s

我有一个适用于我的Logitech G500s的小宏,我在FPS游戏中使用它来减少后座力。 请参见下面的脚本:

EnablePrimaryMouseButtonEvents(truefunction OnEventeventargif event ==“MOUSE_BUTTON_PRESSEDand 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

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

点赞
用户1646982
用户1646982
如果鼠标按键按下并且参数为6,则设置`mb1_pressed`标记,当鼠标按键松开时,取消该标记。因此,只有在按下鼠标按键时变量才会为`true`。

如果您想要在每次按下时切换`mb1_pressed`值,可以使用以下代码:

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

2014-10-30 14:09:45