Hi I'm new to lua programming. I'm trying to get a simple script to work but I can't figure out why it doesn't loop. The debug shows no errors and the console correctly returns the events to me at each mouse click. If I put the outputlogmessage function inside the first loop it doesn't print anything on the screen. I take it that it does not enter the cycle. Can anyone help me, I guess the solution is trivial but I don't understand.
function OnEvent(event, arg)
OutputLogMessage("Event: "..event.." Arg:"..arg.."\n")
if IsMouseButtonPressed(2) then
repeat
if IsMouseButtonPressed(1) then
repeat
MoveMouseRelative (1,-1)
Sleep(8)
until not IsMouseButtonPressed(1)
end
until not IsMouseButtonPressed(2)
end
end
I state that as soon as compiled it worked. After I put the pc in standby and it didn't work anymore.
The mouse buttons enumeration in LGS/GHub is confusing.
For argument of function IsMouseButtonPressed()
:
1=LMB, 2=MMB, 3=RMB
For value of arg
(parameter of function OnEvent
):
1=LMB, 2=RMB, 3=MMB
Please note that right and middle buttons are swapped.
You need to use IsMouseButtonPressed(3)
for RMB.