Reputation: 15
i am trying to make a script for logitech mouse that : when i aim on a game mouse 3 and press fire the mouse goes fast down for about 0.5 secs and the rest of the time until i release the firebutton 1 it goes slower down. code:
error in line 8(sleep(1))
function OnEvent(event, arg)
if IsMouseButtonPressed(3)then
repeat
if IsMouseButtonPressed(1) then
i=1
repeat
i= i + 1
MoveMouseRelative(0,1)
Sleep(1)
until i=1000000000 or (not IsMouseButtonPressed(1))
if IsMouseButtonPressed(3)then
repeat
MoveMouseRelative(0,1)
Sleep(33)
until not IsMouseButtonPressed(1)
end
end
until not IsMouseButtonPressed(3)
end
end
This works but not with the extra 0.5s faster responce in the start
function OnEvent(event, arg)
if IsMouseButtonPressed(3)then
repeat
if IsMouseButtonPressed(1) then
repeat
MoveMouseRelative(0,1)
Sleep(33)
until not IsMouseButtonPressed(1)
end
until not IsMouseButtonPressed(3)
end
end
Upvotes: 0
Views: 2653
Reputation: 974
error in line 8(sleep(1))
No, the error is in line 9 . This is a bug in LGS: for example, the error in the first line it would display as "line #0", etc.
i=1000000000
This is your actual error.
Replace it with i==1000000000
.
In Lua the single =
is used for assignments, and the double ==
is used for equality testing.
Upvotes: 2
Reputation: 28958
Just to add some additional information:
Instead of
if IsMouseButtonPressed(1) then
repeat
MoveMouseRelative(0,1)
Sleep(33)
until not IsMouseButtonPressed(1)
end
You can simply write
while IsMouseButtonPressed(1) do
MoveMouseRelative(0,1)
Sleep(33)
end
Upvotes: 0