Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


TOO FAST!!

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Sun Jul 26, 2020 3:02 pm    Post subject: TOO FAST!! Reply with quote

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 Wink
Back to top
View user's profile Send private message  
ParkourPenguin
I post too much
Reputation: 150

Joined: 06 Jul 2014
Posts: 4657

PostPosted: Sun Jul 26, 2020 4:15 pm    Post subject: This post has 1 review(s) Reply with quote

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.
Back to top
View user's profile Send private message  
Oxijen
Expert Cheater
Reputation: 0

Joined: 07 May 2020
Posts: 163
Location: On The Moon

PostPosted: Mon Jul 27, 2020 2:28 am    Post subject: Reply with quote

Thanks, that was very helpful : D !!
_________________
I can see you Hitler
Especially When I am On the Moon!!
You are Right now in cheat engine forum Wink
Back to top
View user's profile Send private message  
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites