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 


Pause in lua script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
SomeoneElse123
Newbie cheater
Reputation: 0

Joined: 30 Dec 2018
Posts: 11

PostPosted: Sat Jan 05, 2019 7:07 am    Post subject: Pause in lua script Reply with quote

Hi, I'm working on my lua script and I want to ask if ce offers any function how to inject a small pause to the script. It does one function, then does nothing for a second or two and then it does the next function. If anyone knows how to do that, please let me know
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25284
Location: The netherlands

PostPosted: Sat Jan 05, 2019 8:50 am    Post subject: Reply with quote

sleep(timeinmilliseconds) (best used in a thread)

or timer

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sat Jan 05, 2019 12:17 pm    Post subject: Reply with quote

You could try running a loop while statement with calling processMessages() so cheat engine will respond at least, it can work but there will be much performance penalties.

I wrote an example of how to use threads (for this kind of actions - delayed actions).
It uses threads suspend and resume, which saves us lot's of cpu (better than using sleep function and especially for/while loops)

https://forum.cheatengine.org/viewtopic.php?p=5744228#5744228

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Sat Jan 05, 2019 3:47 pm    Post subject: Reply with quote

Look into coroutines for Lua, this is what they are for.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Scorm
Newbie cheater
Reputation: 0

Joined: 06 Dec 2018
Posts: 11

PostPosted: Sun Jan 06, 2019 1:07 pm    Post subject: Reply with quote

atom0s is right, look into coroutines and yield() to have an effective solution that doesn't "do nothing for X seconds".

Otherwise, you might want to create a timer on a form with the desired wait time interval.
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