【发布时间】:2019-05-20 07:42:22
【问题描述】:
我提前道歉,因为我确信这个问题已经得到解答,但是没有任何编程经验,我很难将其他帖子中的解决方案翻译成我自己的代码。我有一个 for 循环,我想在每个间隔期间检查一个全局变量。下面的代码不起作用,因为它认为“continue_loop”是一个局部变量。有什么建议吗?
if (event == "MOUSE_BUTTON_PRESSED" and arg == 1) then
continue_loop = 1
Click()
end
if (event == "M_RELEASED" and arg == 3) then
Click()
end
if (event == "MOUSE_BUTTON_RELEASED" and arg == 1) then
Stopclick()
end
function Stopclick()
continue_loop = 0
end
function Click()
PressMouseButton(1)
Sleep (10)
ReleaseMouseButton(1)
for i=1,10 do
if (continue_loop == 1) then
MoveMouseRelative(0,5)
Sleep (30)
else return
end
end
if (continue_loop == 0) then
Stopclick()
elseif (continue_loop == 1) then SetMKeyState(3)
else Stopclick()
end
end
【问题讨论】:
-
如果您只将
continue_loop设置为0或1之外的任何一个,您如何期望它是这两者? -
我不希望它是
0或1之外的任何其他值。基本上我只是希望能够在循环完成之前在需要时打破循环,这就是我想出的。我不懂编程,所以我相信还有更优雅的解决方案。
标签: lua logitech-gaming-software