Joined: 07 May 2020 Posts: 163 Location: On The Moon
Posted: Sun Jul 26, 2020 3:02 pm Post subject: TOO FAST!!
I have made a simple mouse coordinates recorder.
Code:
datax = {}
datay = {}
function start()
for i = 1, #datax do
setMousePos(datax[i],datay[i])
sleep(1)
end
datax = {}
datay = {}
end
t = createTimer()
t.setInterval(1)
t.OnTimer = function()
x,y = getMousePos()
y = tonumber(y)
x = tonumber(x)
table.insert(datax,x)
table.insert(datay,y)
if isKeyPressed(VK_M) then
t.destroy()
start()
end
end
but the start function gets executed much faster than it was saved. any help here??
timer interval is 1 milsec and there is also 1milsec sleep in the for loop _________________
I can see you Hitler
Especially When I am On the Moon!!
You are Right now in cheat engine forum
The resolution of timers is usually 10-16 milliseconds give or take. Setting the interval to one doesn't mean it'll execute every millisecond, just like sleeping for one millisecond doesn't mean it'll wake up in exactly a millisecond. Both will wait for at least one millisecond before continuing; however, the upper bound is never guaranteed (see scheduling).
Trying to update the mouse 1000 times per second is ridiculous. Do it for 10 times per second, and if that's not enough, increase it from there. Log the time the mouse position was recorded and use that to play it back (getTickCount; also see MS doc).
You may want to play it back in a separate thread so that CE's GUI doesn't become unresponsive. _________________
I don't know where I'm going, but I'll figure it out when I get there.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum