首页 > 解决方案 > 我如何将这 2 个不同的 Lua 脚本合并到一个中?它适用于我的罗技鼠标,我无法组合这 2 个切换脚本

问题描述

您好,我想结合这 2 个切换脚本。这是为了游戏。我不擅长这个脚本,我需要合并脚本的帮助。我想

脚本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 == 7) then
    recoil = not recoil
    spot = not spot
  end

  if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil) then
    if recoil then
      repeat

        Sleep(2)
        MoveMouseRelative(-1, 1)
        Sleep(2)
        MoveMouseRelative( 0.5 , 2)
        Sleep(2)
        MoveMouseRelative( 1, 30)
        Sleep(6)

      until not IsMouseButtonPressed(1)

    end
  end
end

脚本2

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 == 8) then
    recoil = not recoil
    spot = not spot
  end

  if (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil) then
    if recoil then
      repeat

        Sleep(2)
        MoveMouseRelative(-1, 1)
        Sleep(2)
        MoveMouseRelative( 0.5 , 2)
        Sleep(2)
        MoveMouseRelative( 1, 10)
        Sleep(6)

      until not IsMouseButtonPressed(1)

    end
  end
end

标签: lualogitech-gaming-software

解决方案


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
   elseif event == "MOUSE_BUTTON_PRESSED" and (arg == 7 or arg == 8) then     
      recoil = recoil ~= arg and arg
   elseif event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil == 7 then
      repeat
         Sleep(2)
         MoveMouseRelative(-1, 1)
         Sleep(2)
         MoveMouseRelative( 0.5 , 2)
         Sleep(2)
         MoveMouseRelative( 1, 30)
         Sleep(6)
      until not IsMouseButtonPressed(1)
   elseif event == "MOUSE_BUTTON_PRESSED" and arg == 1 and recoil == 8 then
      repeat
         Sleep(2)
         MoveMouseRelative(-1, 1)
         Sleep(2)
         MoveMouseRelative( 0.5 , 2)
         Sleep(2)
         MoveMouseRelative( 1, 10)
         Sleep(6)
      until not IsMouseButtonPressed(1)
   end
end

推荐阅读