Ghub lua 脚本更新
新增功能: playmarco执行时,受到倒计时器或者终止键的钳制,触发后立即停止执行,并可按预设继续执行其他脚本、宏。
请按照我《居然能让一只鼠标搭载999999个待用宏?》内的vscode设置,将代码复制到vs的ide当中,以便用更优雅、易懂的方式修改。
全量代码如下:
--声明一些global变量(全球变量,部分变量必须在代码开始时声明,不然报错)
Marco_Point = 0
guaji_Point = 0
timer = 0
exit_key = 0
function OnEvent(event, arg)
--OutputLogMessage("Event: " .. event .. " Arg: " .. arg .. "\n")
--OutputLogMessage("Marco_Point : " .. Marco_Point .. "\n")
if (event == "MOUSE_BUTTON_PRESSED" and arg == 6 and Marco_Point == 1) then
timer = 0
exit_key = 0
Sleep(50)
PlayMacro("eee")
repeat
timer = timer + 1
Sleep(500)
if IsMouseButtonPressed(3) then --304鼠标右键ghub lua中代码为3
exit_key = 1
end
-- OutputLogMessage(" timer : " .. timer .. "/20 exit_key : " .. exit_key .. "\n")
until (exit_key == 1 or timer > 2 * 10)
Sleep(100)
AbortMacro()
Sleep(100)
-- OutputLogMessage("done: " .. "\n")
PressKey(1) --模拟按下esc,个别游戏内需要按一下esc,以便暂停游戏。
Sleep(100)
ReleaseKey(1) --模拟抬起esc
Sleep(100)
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 2) then --304鼠标-普通右键超级终止
Sleep(50)
Marco_Point = 0
guaji_Point = 0
exit_key = 1
AbortMacro()
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 5) then --304鼠标-前进侧键增加计数器甲计数
Sleep(50)
Marco_Point = Marco_Point + 1
end
if (event == "MOUSE_BUTTON_PRESSED" and arg == 4) then --304鼠标-前进侧键增加计数器乙计数
Sleep(50)
guaji_Point = guaji_Point + 1
end
end