|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
airvzxf How do I cheat? Reputation: 0
Joined: 16 Jul 2020 Posts: 4
|
Posted: Sun Aug 09, 2020 5:06 am Post subject: Lua/CEA, Uncheck the box in the CE (Not in a Trainer) |
|
|
Using the main window for CE, I created some cheats and they are always a checkbox but a couple of this Cheats are call functions executed in a thread, I want to convert the checkbox to button or programmatically I want to uncheck the box.
Code: |
// FillGoldCheat
[ENABLE]
alloc(threadstart, 2048)
threadstart:
call "Realmforge.Client:RTreasureManager:FillGoldCheat"
ret
createthread(threadstart)
dealloc(threadstart)
{$lua}
--print(this.State)
--print(this.Checked)
--if checkBoxes[4].Checked then
-- this.State = 0 -- Uncheck the box
--end
[DISABLE]
|
I attached the idea doing graphically.
Description: |
|
Filesize: |
107.13 KB |
Viewed: |
1962 Time(s) |
|
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Sun Aug 09, 2020 6:06 am Post subject: |
|
|
May added this lua snippet:
Code: |
{$lua}
if not syntaxcheck then
synchronize(createTimer,5000,memrec.setActive,false)
end
{$asm}
|
this need ce ver 7.1+
otherwise use this
Code: |
{$lua}
if not syntaxcheck then
synchronize(function()
local t = createTimer()
t.Interval,t.OnTimer = 5000,function(tm)
tm.Destroy()
memrec.Active = false
end
end)
end
{$asm}
|
the script schedule a timer event to set Active property of the script's memory record (variable memrec) to false after 5000 milisecond.
ADDED:
you place dealloc with Alloc in same [ENABLE] section which may cause error. Should dealloc be in [DISABLE] section?
_________________
- Retarded. |
|
Back to top |
|
|
Csimbi I post too much Reputation: 94
Joined: 14 Jul 2007 Posts: 3108
|
Posted: Sun Aug 09, 2020 6:16 am Post subject: |
|
|
Dungeons 3... have the patches stopped raining?
I'd recommend a different approach.
Set up a timer that checks a flag.
If the flag is false, nothing happens.
If the flag is true, a) call ::FillGoldCheat and b) set flag to false.
Then, set up a hotkey that sets the flag to true.
Now you can leave it on as long as you want and tap the hotkey whenever you need to.
|
|
Back to top |
|
|
airvzxf How do I cheat? Reputation: 0
Joined: 16 Jul 2020 Posts: 4
|
Posted: Sun Aug 09, 2020 12:50 pm Post subject: |
|
|
panraven wrote: | May added this lua snippet:
Code: |
{$lua}
if not syntaxcheck then
synchronize(createTimer,5000,memrec.setActive,false)
end
{$asm}
|
this need ce ver 7.1+
otherwise use this
Code: |
{$lua}
if not syntaxcheck then
synchronize(function()
local t = createTimer()
t.Interval,t.OnTimer = 5000,function(tm)
tm.Destroy()
memrec.Active = false
end
end)
end
{$asm}
|
the script schedule a timer event to set Active property of the script's memory record (variable memrec) to false after 5000 milisecond.
ADDED:
you place dealloc with Alloc in same [ENABLE] section which may cause error. Should dealloc be in [DISABLE] section? |
Thank you, it's just what I was looking. I changed to 500 ms.
Answering your "ADD", it didn't crash and I had the same concern, I thinks so that it dealloc after the thread instructions are finished; Also I don't want to delloc on disable because this is a one-shoot execution, create the thread, execute and delete the thread.
Why I think that it's not crashing?
Alloc in memory -> alloc(threadstart, 2048)
Execute -> createthread(threadstart)
Go inside of the code ->
threadstart:
call "Realmforge.Client:RTreasureManager:FillGoldCheat"
ret
After execute the code it dealloc -> dealloc(threadstart)
---
Csimbi wrote: | Dungeons 3... have the patches stopped raining?
I'd recommend a different approach.
Set up a timer that checks a flag.
If the flag is false, nothing happens.
If the flag is true, a) call ::FillGoldCheat and b) set flag to false.
Then, set up a hotkey that sets the flag to true.
Now you can leave it on as long as you want and tap the hotkey whenever you need to. |
In fact it's Dungeons 2 and yes the last update in steam was on 23 July 2018 (748 days ago) but I like play old games, in fact some times I play Final Fantasy 1 for Nes or the classic Sega games.
Thanks for provide a different approach about how to solve it, in this case for me, it will be much better to apply your suggestion if I create a Trainer because I would able to use shortcuts for active and de-active the cheats.
Thanks again.
---
ParkourPenguin wrote: | That's absolutely a race condition. The created thread might not finish executing before CE deallocates the memory.
Example of how to do it well:
forum.cheatengine.org/viewtopic.php?p=5722316#5722316 |
This is awesome, right now it's not crashing but I'll try later for research or if I had some problem. Thanks a lot.
---
Last edited by airvzxf on Sun Aug 09, 2020 4:06 pm; edited 1 time in total |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4289
|
Posted: Sun Aug 09, 2020 2:40 pm Post subject: |
|
|
That's absolutely a race condition. The created thread might not finish executing before CE deallocates the memory.
Example of how to do it well:
https://forum.cheatengine.org/viewtopic.php?p=5722316#5722316
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Sun Aug 09, 2020 3:50 pm Post subject: |
|
|
Code: |
... I thinks so that it dealloc after the thread instructions are finished...
|
read ParkourPenguin response.
Actually, even you simply move dealloc into [disable], the race condition is still there.
Csimbi's suggestion is safer.
ADDED:
there may be a third option.
There is a lua mono function
mono_invoke_method(domain, method, object, args)
In the AA script or UI handler just call the mono function with appropriate lua parameters.
For your particular function, it should be a static function without other parameters, so object (the this instance address) can be set as 0, args as empty table {}, method be your function as symbol address (type string).
What leave is the domain. This can be obtain by
Code: |
...
local fn = "Realmforge.Client:RTreasureManager:FillGoldCheat"
local domains=mono_enumDomains()
local domain = domains and #domains>0 and domains[1]
if domain then mono_invoke_method(domain, fn, 0, {} )end
...
|
or just use executeCode (execute function in attached process) for this particular no parameter function
Code: |
...
local fn = "Realmforge.Client:RTreasureManager:FillGoldCheat"
executeCode(fn)
...
|
_________________
- Retarded. |
|
Back to top |
|
|
|
|
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
|
|