Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行同步重复循环Lua脚本Logitech GHUB_Lua_Logitech_Logitech Gaming Software - Fatal编程技术网

运行同步重复循环Lua脚本Logitech GHUB

运行同步重复循环Lua脚本Logitech GHUB,lua,logitech,logitech-gaming-software,Lua,Logitech,Logitech Gaming Software,这是我第一次尝试LUA所以请容忍我 我试图同时组合几个我想循环的函数,但我只能让它们按顺序运行。 理想情况下,绑定到鼠标按钮6的功能会在按下时启动,释放时停止(目前它根本不会停止!!)。另外,按下鼠标按钮3时,该功能将运行,释放时停止(此按钮不会停止) 目前,按钮3循环正常工作,但按钮6循环并未结束 理想情况下,我希望两者都能在按下和释放各自的按钮时工作和停止,和,以便它们在同时按下3和6时同时运行 这可以做到吗?如果可以的话,我需要做什么改变来实现这一点 EnablePrimaryMouseB

这是我第一次尝试LUA所以请容忍我

我试图同时组合几个我想循环的函数,但我只能让它们按顺序运行。 理想情况下,绑定到鼠标按钮6的功能会在按下时启动,释放时停止(目前它根本不会停止!!)。另外,按下鼠标按钮3时,该功能将运行,释放时停止(此按钮不会停止)

目前,按钮3循环正常工作,但按钮6循环并未结束

理想情况下,我希望两者都能在按下和释放各自的按钮时工作和停止,,以便它们在同时按下3和6时同时运行

这可以做到吗?如果可以的话,我需要做什么改变来实现这一点

EnablePrimaryMouseButtonEvents(true);
 
function OnEvent(event, arg)
    if event == "MOUSE_BUTTON_PRESSED" and arg == 6 then
        repeat
            MoveMouseRelative(300,0)
                Sleep(150)
                MoveMouseRelative(-300,0)
                Sleep(1500)
    until event == "MOUSE_BUTTON_RELEASED" and arg == 6
    elseif IsMouseButtonPressed(3) then
        repeat  
            MoveMouseRelative(0,300)
            Sleep(1000)
        until not IsMouseButtonPressed(3)
    end
end

提前感谢:D

第1步。
确保您在游戏中没有使用MB#4(“后退”)。
如果您在游戏中不使用MB#4,请跳过“步骤1”。
如果游戏中某些动作分配给MB#4,请执行以下操作:

  • 选择游戏中当前未使用的键盘按钮(例如,
    F12
  • goto GHUB(键选项卡);将
    F12
    绑定到物理MB#4
  • 转到游戏选项;将操作绑定到
    F12
    而不是MB#4
现在,当你按下物理MB#4时,游戏会看到F12并激活你的旧动作


第2步。
转到GHUB(系统选项卡)
从MB#4取消绑定“后退”
将“返回”绑定到MB#6


第三步。
剧本

local all_buttons = {
   [4] = {  -- mouse button #6
      {time=0,   x=50 }, -- at time 0 move mouse right 50 pixels
      {time=150, x=-50}, -- at time 150 move mouse left 50 pixels
      {time=150+1500},   -- at time 150+1500 repeat the loop
   },
   [3] = {  -- right mouse button
      {time=0, y=50},  -- at time 0 move mouse down 50 pixels
      {time=1000},     -- at time 1000 repeat the loop
   }
}

function OnEvent(event, arg)
   if event == "PROFILE_ACTIVATED" then
      EnablePrimaryMouseButtonEvents(true)
   elseif event == "MOUSE_BUTTON_PRESSED" then
      repeat
         Sleep(10)
         local tm = GetRunningTime()
         local some_loop_is_active
         for btn_no, info in pairs(all_buttons) do
            if not info.started and IsMouseButtonPressed(btn_no) then
               info.started = tm
               info.next_step = 1
            end
            some_loop_is_active = some_loop_is_active or info.started
            local next_action = info[info.next_step]
            if info.started and tm - info.started >= next_action.time then
               info.next_step = info.next_step + 1
               local x, y = next_action.x, next_action.y
               if x or y then
                  x, y = x or 0, y or 0
                  local sx, sy = x < 0 and -1 or 1, y < 0 and -1 or 1
                  x, y = x*sx, y*sy
                  while x > 0 or y > 0 do
                     local px, py = x < 127 and x or 127, y < 127 and y or 127
                     MoveMouseRelative(px*sx, py*sy)
                     x, y = x-px, y-py
                  end
               else
                  info.started = nil
               end
            end
         end
      until not some_loop_is_active
   end
end
本地所有按钮={
[4] ={--鼠标按钮#6
{time=0,x=50},-在时间0时,将鼠标右移50像素
{time=150,x=-50},-在时间150时,将鼠标向左移动50像素
{time=150+1500},-在时间150+1500重复循环
},
[3] ={--鼠标右键
{time=0,y=50},--在时间0时,将鼠标向下移动50像素
{time=1000},-在时间1000时重复循环
}
}
函数OnEvent(事件,参数)
如果事件==“已激活配置文件”,则
EnablePrimaryMouseButtonEvents(真)
elseif事件==“按下鼠标按钮”,然后
重复
睡眠(10)
本地tm=GetRunningTime()
局部某些循环处于活动状态
对于btn_no,信息成对(所有按钮)执行
如果未启动信息并按下按钮(btn_no),则
info.started=tm
info.next_步骤=1
结束
some\u loop\u处于活动状态=some\u loop\u处于活动状态或信息已启动
本地下一步行动=信息[信息.下一步]
如果info.started和tm-info.started>=下一个动作时间,则
info.next_step=info.next_step+1
局部x,y=下一个动作.x,下一个动作.y
如果x或y那么
x、 y=x或0,y或0
局部sx,sy=x<0和-1或1,y<0和-1或1
x、 y=x*sx,y*sy
当x>0或y>0时
局部px,py=x<127和x或127,y<127和y或127
移动鼠标关联(px*sx,py*sy)
x、 y=x-px,y-py
结束
其他的
info.started=nil
结束
结束
结束
直到没有某个循环处于活动状态
结束
结束
您应该知道MoveMouseRelative()受127像素的限制。
要将鼠标光标移动300像素,应调用鼠标光标3次:

movemouserective(0100);movemouserective(0100);MoveMouseRelative(0100)

第1步。
确保您在游戏中没有使用MB#4(“后退”)。
如果您在游戏中不使用MB#4,请跳过“步骤1”。
如果游戏中某些动作分配给MB#4,请执行以下操作:

  • 选择游戏中当前未使用的键盘按钮(例如,
    F12
  • goto GHUB(键选项卡);将
    F12
    绑定到物理MB#4
  • 转到游戏选项;将操作绑定到
    F12
    而不是MB#4
现在,当你按下物理MB#4时,游戏会看到F12并激活你的旧动作


第2步。
转到GHUB(系统选项卡)
从MB#4取消绑定“后退”
将“返回”绑定到MB#6


第三步。
剧本

local all_buttons = {
   [4] = {  -- mouse button #6
      {time=0,   x=50 }, -- at time 0 move mouse right 50 pixels
      {time=150, x=-50}, -- at time 150 move mouse left 50 pixels
      {time=150+1500},   -- at time 150+1500 repeat the loop
   },
   [3] = {  -- right mouse button
      {time=0, y=50},  -- at time 0 move mouse down 50 pixels
      {time=1000},     -- at time 1000 repeat the loop
   }
}

function OnEvent(event, arg)
   if event == "PROFILE_ACTIVATED" then
      EnablePrimaryMouseButtonEvents(true)
   elseif event == "MOUSE_BUTTON_PRESSED" then
      repeat
         Sleep(10)
         local tm = GetRunningTime()
         local some_loop_is_active
         for btn_no, info in pairs(all_buttons) do
            if not info.started and IsMouseButtonPressed(btn_no) then
               info.started = tm
               info.next_step = 1
            end
            some_loop_is_active = some_loop_is_active or info.started
            local next_action = info[info.next_step]
            if info.started and tm - info.started >= next_action.time then
               info.next_step = info.next_step + 1
               local x, y = next_action.x, next_action.y
               if x or y then
                  x, y = x or 0, y or 0
                  local sx, sy = x < 0 and -1 or 1, y < 0 and -1 or 1
                  x, y = x*sx, y*sy
                  while x > 0 or y > 0 do
                     local px, py = x < 127 and x or 127, y < 127 and y or 127
                     MoveMouseRelative(px*sx, py*sy)
                     x, y = x-px, y-py
                  end
               else
                  info.started = nil
               end
            end
         end
      until not some_loop_is_active
   end
end
本地所有按钮={
[4] ={--鼠标按钮#6
{time=0,x=50},-在时间0时,将鼠标右移50像素
{time=150,x=-50},-在时间150时,将鼠标向左移动50像素
{time=150+1500},-在时间150+1500重复循环
},
[3] ={--鼠标右键
{time=0,y=50},--在时间0时,将鼠标向下移动50像素
{time=1000},-在时间1000时重复循环
}
}
函数OnEvent(事件,参数)
如果事件==“已激活配置文件”,则
EnablePrimaryMouseButtonEvents(真)
elseif事件==“按下鼠标按钮”,然后
重复
睡眠(10)
本地tm=GetRunningTime()
局部某些循环处于活动状态
对于btn_no,信息成对(所有按钮)执行
如果未启动信息并按下按钮(btn_no),则
info.started=tm
info.next_步骤=1
结束
some\u loop\u处于活动状态=some\u loop\u处于活动状态或信息已启动
本地下一步行动=信息[信息.下一步]
如果info.started和tm-info.started>=下一个动作时间,则
info.next_step=info.next_step+1
局部x,y=下一个动作.x,下一个动作.y
如果x或y那么
x、 y=x或0,y或0
局部sx,sy=x<0和-1或1,y<0和-1或1
x、 y=x*sx,y*sy
当x>0或y>0时
局部px,py=x<127和x或127,y<127和y或127
移动鼠标关联(px*sx,py*sy)
x、 y=x-px,y-py