如何使用罗技 LUA 脚本

我正在尝试有两个输入,会有一个输出。这是为了我能在游戏中使用某个技能。谢谢如果你能帮忙。

function OnEvent(event, arg)
     if event == "MOUSE_BUTTON_PRESSED" and arg == 2 then --设置 mb2 标志
            mb2_pressed = true
    elseif event == "MOUSE_BUTTON_RELEASED" and arg == 2 then --设置 mb2 标志为 false
        mb2_pressed = false
    else if event == "LSHIFT_BUTTON_PRESSED" and arg == 1 then
    leftshift_pressed = true
    else if event == "LSHIFT_BUTTON_RELEASED" and arg == 1 then
    leftshift_pressed = false
    end
end

if leftshift_pressed and  if mb2_pressed then
presskey("9")
        Sleep(50)
        releasekey("9")
end
end

https://gyazo.com/7e7f2139fabb22d1e06f8f3f169cb4bb

点赞
用户1847592
用户1847592

``` function OnEvent(event, arg) if event == "MOUSE_BUTTON_PRESSED" and arg == 2 and IsModifierPressed("lshift") then PressAndReleaseKey("lshift") PressAndReleaseKey("9") end end

你需要知道以下内容:

  • LGS/GHUB 在行号上有一个错误,“错误消息中的第12行”实际上是在你的代码中的第13行(并且红色条带的位置也被设置错误了)。
  • if leftshift_pressed and if mb2_pressed then 是一个语法错误,你应该写成if leftshift_pressed and mb2_pressed then
  • if/ elseif/ else/ end 必须平衡。你的代码没有平衡。在代码中使用缩进使其更明显。
  • 没有 LSHIFT_BUTTON_PRESSED 事件,你只能从 G-按钮(所有 Logitech 鼠标上的按钮和 Logitech 键盘上的特殊 G-按钮)接收事件。
  • 大写字母与小写字母不同:PressKey 不同于 presskey
2020-07-13 07:45:43