合并两个Lua脚本?

问题描述 投票:1回答:1

我正在尝试找到一种方法来组合这两个脚本:

    function OnEvent(event, arg)
      OutputLogMessage("event = %s, arg = %d\n", event, arg)
      if (event == "PROFILE_ACTIVATED") then
        EnablePrimaryMouseButtonEvents(true)
      elseif event == "PROFILE_DEACTIVATED" then
        ReleaseMouseButton(2)  -- to prevent it from being stuck on
      end
      if (event == "MOUSE_BUTTON_PRESSED" and arg == 5) then
        recoilx2 = not recoilx2
        spot = not spot
      end
      if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoilx2) then
        if recoilx2 then
          repeat
            MoveMouseRelative(0, 25)
            Sleep(1000)
          until not IsMouseButtonPressed(1)
        end
      end

      if IsMouseButtonPressed(1) then
        repeat
          PressMouseButton(1)
          Sleep(15)
          ReleaseMouseButton(1)
        until not IsMouseButtonPressed(1)
      end
    end

当我按下鼠标5激活第一部分时,底部的重复单击部分无效。

lua logitech
1个回答
0
投票

当我按下鼠标5激活第一部分时,重复单击底部的部分无效。

第一次按下按钮5时出现此条件语句

 if (event == "MOUSE_BUTTON_PRESSED" and arg == 5) then
   recoilx2 = not recoilx2
   spot = not spot
 end

这会将true分配给recoilx2

[之后您按按钮1时,您将得到以下条件语句:

if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoilx2) then
  if recoilx2 then
    repeat
      MoveMouseRelative(0, 25)
      Sleep(1000)
    until not IsMouseButtonPressed(1)
  end
end

这里您等待直到不再按下按钮1。

除非再次按下按钮5来将false分配给recoilx2,否则当您按下按钮1时始终会停留在那里,直到释放按钮1为止。

因此,您永远不能输入此条件语句。

 if IsMouseButtonPressed(1) then
   repeat
     PressMouseButton(1)
     Sleep(15)
     ReleaseMouseButton(1)
   until not IsMouseButtonPressed(1)
 end
© www.soinside.com 2019 - 2024. All rights reserved.