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 


Local script only SLEEP Possible?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Meiyoh
Master Cheater
Reputation: 1

Joined: 14 Mar 2015
Posts: 402

PostPosted: Sun Mar 31, 2019 2:41 am    Post subject: Local script only SLEEP Possible? Reply with quote

How to make a local script for example with lua wait 4 seconds then do what is shall do without pausing entire CHEAT ENGINE ?

Can someone write an example

ie

if isKeyPressed(VK_PAD_B) then Sleep(4000)

AND AFTER THE pause to write what it shall not before


I just want this function to sleep not the entire CE how to do so?

_________________
I am the forgotten one the dead one.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sun Mar 31, 2019 3:58 am    Post subject: Reply with quote

either use threads or a timer

timer:
Code:

...
if isKeyPressed(VK_PAD_B) then
  --do stuff before pause
  local t=createTimer()
  t.Interval=4000
  t.OnTimer=function(t)
    --do stuff after pause
    t.destroy()
  end
end


thread:
Code:

keycheckthread=createThread(function(thr)
while thr.Terminated==false do
  if isKeyPressed(VK_PAD_B) then
    --do stuff before pause
    sleep(4000)
    --do stuff after pause
  end 
  sleep(100) --don't eat up all cpu time
end
end)

_________________
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
Meiyoh
Master Cheater
Reputation: 1

Joined: 14 Mar 2015
Posts: 402

PostPosted: Sun Mar 31, 2019 9:59 am    Post subject: Reply with quote

Dark Byte wrote:
either use threads or a timer

timer:
Code:

...
if isKeyPressed(VK_PAD_B) then
  --do stuff before pause
  local t=createTimer()
  t.Interval=4000
  t.OnTimer=function(t)
    --do stuff after pause
    t.destroy()
  end
end


thread:
Code:

keycheckthread=createThread(function(thr)
while thr.Terminated==false do
  if isKeyPressed(VK_PAD_B) then
    --do stuff before pause
    sleep(4000)
    --do stuff after pause
  end 
  sleep(100) --don't eat up all cpu time
end
end)


Eric I can't thank you enough for this ! This changes a lot of things and surely I will remember that timers can be created inside timers.

WONDERFUL!

_________________
I am the forgotten one the dead one.
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 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