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 


Cheat Engine Forum Index
PostGo back to topic
ParkourPenguin
I post too much
Reputation: 150
Joined: 06 Jul 2014
Posts: 4654

PostPosted: Fri Feb 11, 2022 9:02 pm    Post subject:

In the janky experimentation I'm doing, I guess createTimer might need to be called from the main thread.

Using events like DB suggested in that linked topic would likely be better. Maybe something like this:
Code:
[ENABLE]
{$lua}
if syntaxcheck then return end
if myScriptStuff then
  myScriptStuff.thread.terminate()
  if myScriptStuff.event then
    myScriptStuff.event.setEvent()
  end
  myScriptStuff = nil
end

myScriptStuff = {}
local event = createEvent(false, false)
myScriptStuff.event = event

myScriptStuff.thread = createThread(function(t)
  while not t.Terminated do
    if event.waitFor(0xFFFFFFFF) ~= wrSignaled then break end
    if t.Terminated then break end

    -- your code here
    doKeyPress(69)
    doKeyPress(22531)
  end

  event.destroy()
  if myScriptStuff then myScriptStuff.event = nil end
end)

{$asm}

// your other code
// ...
{$luacode}
myScriptStuff.event.setEvent()
{$asm}
// ...

[DISABLE]
{$lua}
if syntaxcheck then return end
if myScriptStuff then
  myScriptStuff.thread.terminate()
  if myScriptStuff.event then
    myScriptStuff.event.setEvent()
  end
  myScriptStuff = nil
end
{$asm}
// ...

_________________
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
Post reviews:   Approve 1
Author Review
++METHOS
Review: Approve
Post reference:
ReviewPosted: Sat Feb 12, 2022 11:05 pm


Back to top
View user's profile Send private message
Display:  
Cheat Engine Forum Index


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites