View previous topic :: View next topic |
Author |
Message |
Suuper How do I cheat?
Reputation: 0
Joined: 18 Jul 2015 Posts: 5
|
Posted: Sat Jul 18, 2015 9:56 pm Post subject: Manually Stop Thread |
|
|
I have a Lua script which runs an infinite loop in a separate thread, but I want to be able to manually stop that thread.
Is there a way to do this, besides something like closing CE?
|
|
Back to top |
|
 |
Daijobu Master Cheater
Reputation: 13
Joined: 05 Feb 2013 Posts: 301 Location: the Netherlands
|
Posted: Sun Jul 19, 2015 12:16 am Post subject: |
|
|
Can we see your code or pseudocode?
You can use a toggle, set up a variable and check it every time it loops to be true. If not true then continue loop.
If true (manually) loop will exit.
_________________
|
|
Back to top |
|
 |
Suuper How do I cheat?
Reputation: 0
Joined: 18 Jul 2015 Posts: 5
|
Posted: Sun Jul 19, 2015 1:18 pm Post subject: |
|
|
Here's how I have the infinite loop set up:
Code: | function doWork()
--Do some stuff
while (true) do
--Do more stuff
end
end
createNativeThread(doWork); |
|
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Jul 19, 2015 1:32 pm Post subject: |
|
|
Wow, that must be killing your CPU.
Does this work?
Code: | [ENABLE]
${lua}
KEEP_GOING = true
function doWork()
--Do some stuff
while (KEEP_GOING) do
--Do more stuff
end
end
createNativeThread(doWork);
{$asm}
[DISABLE]
{$lua}
KEEP_GOING = false
{$asm} |
|
|
Back to top |
|
 |
Suuper How do I cheat?
Reputation: 0
Joined: 18 Jul 2015 Posts: 5
|
Posted: Sun Jul 19, 2015 2:03 pm Post subject: |
|
|
Zanzer wrote: | Wow, that must be killing your CPU.
Does this work?
Code: | [ENABLE]
${lua}
KEEP_GOING = true
function doWork()
--Do some stuff
while (KEEP_GOING) do
--Do more stuff
end
end
createNativeThread(doWork);
{$asm}
[DISABLE]
{$lua}
KEEP_GOING = false
{$asm} |
|
What is {$lua/asm} and [EN/DISABLE] supposed to do? When I paste that into my script I get an error message: "unexpected symbol near '['" on the line with [ENABLE].
(@killing my CPU: Part of my "do more stuff" is using sleep, waiting for when it's supposed to actually happen.)
|
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Jul 19, 2015 3:45 pm Post subject: |
|
|
Those commands are used for Cheat Engine's table entry scripts.
If you're adding scripts elsewhere, ignore those commands.
The main part was to replace "while (true)" with a variable you can change.
You'll need to create a separate action which executes:
|
|
Back to top |
|
 |
Suuper How do I cheat?
Reputation: 0
Joined: 18 Jul 2015 Posts: 5
|
Posted: Mon Jul 20, 2015 10:11 pm Post subject: |
|
|
I got it to work using a cheat table with a form, using a button to start/stop the script.
Thanks for the helps.
|
|
Back to top |
|
 |
|