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 


Looking for a way to pause engine (Sleep doesn't do it)

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

Joined: 10 Nov 2018
Posts: 14

PostPosted: Sun Nov 25, 2018 10:00 am    Post subject: Looking for a way to pause engine (Sleep doesn't do it) Reply with quote

I'm trying to update the caption on a control element, right before I do a memory scan. Unfortunately, the engine is so fast, that it ties itself up with the scan right away, and the caption is never updated (until it's all over).
I tried to put a Sleep command before it (even as long as 1 sec), but that didn't help.
Is there any other way to tell the engine to take a little breather?
Code:
function CEButton1Click(sender)
  control_setCaption(CETrainer_CEEdit1, "searching") -- never shows up
  Sleep(1000) -- doesn't help

  print("start")
  ms=createMemScan()
  memscan_firstScan(ms, soValueBetween, vtSingle, rtRounded, 0, 10000, 0x00000000, 0x00007fffffffffff, "", fsmNotAligned, "", false, false, false, false)
  memscan_waitTillDone(ms)
  fl=createFoundList(ms)
  foundlist_initialize(fl)
  count=foundlist_getCount(fl)
  object_destroy(fl)
  object_destroy(ms)
  print("done, "..count.." matches")

  control_setCaption(CETrainer_CEEdit1, "done") -- never shows up
  Sleep(2000)
  control_setCaption(CETrainer_CEEdit1, "-") -- this is the only update shown
end
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4711

PostPosted: Sun Nov 25, 2018 10:56 am    Post subject: Reply with quote

Lua still has control over the main thread. You have to explicitly tell CE to process GUI messages.
Code:
CETrainer.STARTPOS.Caption = 'Searching...'
processMessages()
local ms = createMemScan()
ms.firstScan(soValueBetween, vtSingle, rtRounded, startXmin, startXmax, 0x00000000, 0x00007fffffffffff, '', fsmNotAligned, '', false, false, false, false)
ms.waitTillDone()

You could also use OnScanDone or wait in a separate thread.

_________________
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
User100
Newbie cheater
Reputation: 0

Joined: 10 Nov 2018
Posts: 14

PostPosted: Sun Nov 25, 2018 11:33 am    Post subject: Reply with quote

Ah, yes... That's what I needed.
processMessages() is doing exactly what I was looking for.

Thanks a bunch!
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