我如何将这2个不同的Lua脚本合并为一个?这是为我的罗技鼠标设计的,我无法结合使用这2个切换脚本 [英] How i can merge this 2 different Lua script in ONE? it is for my logitech mouse and i am not able to combine this 2 toggle script

查看:265
本文介绍了我如何将这2个不同的Lua脚本合并为一个?这是为我的罗技鼠标设计的,我无法结合使用这2个切换脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想结合使用这2个切换脚本.这是一个游戏.我不擅长此脚本,并且需要合并脚本的帮助.我想要

Hello I want to combine this 2 toggle script. It is for a game. I am not good at this script and I need help for merge scripts. I would like

  • 当我按下G7按钮时
    按下鼠标左键时鼠标将x像素下拉
  • 当我按下g8按钮时
    当我按下鼠标左键时,鼠标将y像素向下拉.

脚本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


Script2


Script2

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

推荐答案

不确定您要做什么,但这听起来与您要实现的目标相似.您可能需要添加一些 MoveMouseRelative(x,y)坐标对以使其正确对准目标,但这应该与您正在寻找的逻辑近似.

Not entirely certain what you are going for, but this sounds similar to what you are trying to achieve. You might need to add a few MoveMouseRelative(x, y) coordinate pairs to get it to aim right, but this should approximate the logic you're looking for.

function OnEvent( event, arg )
    OutputLogMessage( 'event = %s, arg = %d\n',  event,  arg )

    if event == 'PROFILE_ACTIVATED' then
        EnablePrimaryMouseButtonEvents( true )

    elseif event == 'PROFILE_DEACTIVATED' then
        EnablePrimaryMouseButtonEvents( false )

    --~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    elseif event == 'MOUSE_BUTTON_PRESSED' and arg == 7 then
        spot = not spot  --  toggle horizontal X spot-drift by pressing button 7

    elseif event == 'MOUSE_BUTTON_PRESSED' and arg == 1 and spot then
        while IsMouseButtonPressed( 1 ) do
            MoveMouseRelative( -1, 0 )  --  left on the X axis, enable/disable with button 7
            Sleep( 2 )
        end

    --~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    elseif event == 'MOUSE_BUTTON_PRESSED' and arg == 8 then
        recoil = not recoil  --  toggle vertical Y recoil-compensation by pressing button 8

    elseif event == 'MOUSE_BUTTON_PRESSED' and arg == 1 and recoil then
        while IsMouseButtonPressed( 1 ) do
            MoveMouseRelative( 0, 1 )  --  down on the Y axis, enable/disable with button 8
            Sleep( 2 )
        end
    end
end

这篇关于我如何将这2个不同的Lua脚本合并为一个?这是为我的罗技鼠标设计的,我无法结合使用这2个切换脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆