View previous topic :: View next topic |
Author |
Message |
sgsgwv$6263 Advanced Cheater Reputation: 0
Joined: 05 Aug 2020 Posts: 75
|
Posted: Sun Jan 08, 2023 11:41 am Post subject: How to set up custom events and it's event handler |
|
|
I want to run a code whenever the value of a memory address has a value x. I don't want timer based solution (I think they are inefficient, please prove me wrong) . For now I am using hotkeys to do such things. But I don't want to constantly press a button for this use case(I have to press it too frequently) . But I recently found a static address let's say y. I want to do something like "when y has value x run this code". This can be done with code injection also but I don't want to use assembly. I am comfortable with lua not with asm. Maybe if someone can suggest me a way to inject lua function inside assembly that would help. |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4289
|
Posted: Sun Jan 08, 2023 12:34 pm Post subject: |
|
|
sgsgwv$6263 wrote: | For now I am using hotkeys to do such things. But I don't want to constantly press a button for this use case(I have to press it too frequently) . | Just use a timer. Increase the interval to however frequently you press the hotkey and it'll be the same.
If the value doesn't get written to that often, you could use a breakpoint.
Worst case, you could use code injection and {$luacode}. (I think {$luacode} would be about as bad as a breakpiont- use assembly to skip over the {$luacode} block if it isn't the right value) _________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1253
|
Posted: Sun Jan 08, 2023 2:14 pm Post subject: |
|
|
If you have fixed addresses (where x values are read and y values are read), you can compare them with the lua code and add something based on the result.
You can use this interchangeably with "{$lua}", "{$asm}" in asm.
And yes, it makes more sense to use a timer if the reading is not predictive or instantaneous.
You can handle this in a single script and with a hotkey assigned to it. _________________
|
|
Back to top |
|
|
sgsgwv$6263 Advanced Cheater Reputation: 0
Joined: 05 Aug 2020 Posts: 75
|
Posted: Sun Jan 08, 2023 10:23 pm Post subject: |
|
|
Thanks for help both of you. But I have never used a script with {$lua} and {$asm} togather. I have used lua and asm togather before but somehow my lua code cannot access the register values if I inject the lua code between asm. Or even if I call print() , the call happens just when I activate the script and not when the the processor executes the asm code. I think it skips over the lua code(?).
Seeing something like this:
https://www.cheatengine.org/forum/viewtopic.php?t=577027&sid=9a8df847d55270ea27d2ef2756b7ca86
I think it's too much boilerplate code for calling a single function. Can you elaborate whats going on in DB's code in this link or provide a simple alternative solution like that.
Also, the value doesnot get written periodically. It depends on what happens in the game. |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4289
|
Posted: Sun Jan 08, 2023 10:36 pm Post subject: |
|
|
{$lua} is just for preprocessing stuff before the AA script actually gets run (a returned string gets put into the script). {$luacode} is for injecting Lua code that gets run from a code injection.
Again, I would highly recommend just using a timer. It's by far the simplest solution. If it's not fast enough, you're doing something wrong and it's very likely no other solution will be fast enough. Lua code is always run by CE: {$luacode} necessarily involves synchronous IPC. This is not fast.
If you insist on {$luacode}:
https://forum.cheatengine.org/viewtopic.php?t=618134
If you gave more details about whatever it is you're trying to do, you could get better help. Post the code you have so far. _________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
sgsgwv$6263 Advanced Cheater Reputation: 0
Joined: 05 Aug 2020 Posts: 75
|
Posted: Sun Jan 08, 2023 10:57 pm Post subject: |
|
|
Okay. Thanks. I think timers will be okay if {$luacode} is that bad.
But in luacode, will the registers be available for use like eax will be in EAX variable?
What I am trying to do: currently I have set a hotkey that sets a breakpoint at an asm code. On breakpoint,Based on certain condition writes something to eax register. Another hotkey is set for removing the breakpoint. The value that I am changing is not in any memory address, it's only in that eax register at the BP address.
But all this has to be done frequently. It's a code which is trying to set field positions for a baseball game. Game doesnot allow field positions other than the in built positions. I have to press this hotkey everytime the pitcher is ready to throw the ball so that before he throws the ball I can set the coordinates of the fielders with my script using these hotkeys. |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1253
|
Posted: Mon Jan 09, 2023 5:34 am Post subject: |
|
|
sgsgwv$6263 wrote: | Okay. . I have to press this hotkey everytime the pitcher is ready to throw the ball so that before he throws the ball I can set the coordinates of the fielders with my script using these hotkeys. |
Let's assume the ready position is 1, and the non-ready value is 0.
If you can find an address that will give you this value, we can develop a good idea for your code.
The required address should give the following values:
It must give values indicating that the ball in the pitcher is pending (not ready) or ready.
If you find the address that says these values, we're done.
(A similar lua code has been rendered recently.)
https://forum.cheatengine.org/viewtopic.php?p=5780987#5780987 _________________
|
|
Back to top |
|
|
|