lua - 我如何将这 2 个不同的 Lua 脚本合并到一个中?它适用于我的罗技鼠标,我无法组合这 2 个切换脚本
问题描述
您好,我想结合这 2 个切换脚本。这是为了游戏。我不擅长这个脚本,我需要合并脚本的帮助。我想
- 当我按下 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
脚本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
解决方案
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
推荐阅读
- mongodb - Pymongo - 纪元日期过滤器查询不适用于集合
- discord.js - 在嵌入页面中显示公会并为每个公会添加一个反应
- r - 根据下一个 R 替换 df 中的值
- php - Laravel 自递归关系
- r - 向量中的所有可能组合
- mysql - 在日期列中使用 varchar 数据类型按日期分组
- ios - 将 JSON 数组解包成 Swift 对象
- arrays - 分配数组 [ArraySize] 是否正确?这里 ArraySize 是用户给出的输入
- python - 带有 tf.hessians 的 keras 模型的 hessian 矩阵
- javascript - 尝试获取特定数据但得到“无法读取 XMLHttpRequest.xhr.onreadystatechange 处未定义的属性 '0'”