View previous topic :: View next topic |
Author |
Message |
Meiyoh Master Cheater
Reputation: 1
Joined: 14 Mar 2015 Posts: 402
|
Posted: Fri Aug 07, 2020 2:47 am Post subject: CE Make Hotkeys more responsive |
|
|
thanks for help
_________________
I am the forgotten one the dead one.
Last edited by Meiyoh on Sat Aug 08, 2020 1:53 am; edited 1 time in total |
|
Back to top |
|
 |
Csimbi I post too much
Reputation: 97
Joined: 14 Jul 2007 Posts: 3321
|
Posted: Fri Aug 07, 2020 12:00 pm Post subject: |
|
|
Well, these are not really hotkeys, right?
This is just a code that checks for specific keys every now and then.
Anyway, since you went this way, you should put in else statements to control the flow, so it skips everything once the right key was found and you should also make sure the code can finish up before the next timer tick (or maybe run in a separate thread?).
|
|
Back to top |
|
 |
Meiyoh Master Cheater
Reputation: 1
Joined: 14 Mar 2015 Posts: 402
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4700
|
Posted: Fri Aug 07, 2020 2:05 pm Post subject: |
|
|
Meiyoh wrote: | I am wondering what triggers the hotkeys in the lua to be unresponsive at times? | I'm not certain, but your incredibly inefficient code doesn't help.
Every call to read*/write* is an API call to ReadProcessMemory/WriteProcessMemory. This gets expensive if you make a lot of calls in a loop.
Try to minimize the number of read*/write* calls you make each iteration. Better code flow can help ("elseif" is a thing in Lua), as well as caching things like symbol lookups (especially pointer paths) and values:
Code: | local addr = getAddress('[myAddress]')
local value1 = readInteger(addr+0x10)
if value1 == 5 then
writeInteger(addr+0x18, 9)
elseif value1 == 7 then
writeInteger(addr+0x20, 13)
end | And format your code better. I stopped reading it after the first few lines.
Csimbi wrote: | This is just a code that checks for specific keys every now and then. | That's actually kind of how hotkeys work in CE's source, but CE does it far more efficiently.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
Csimbi I post too much
Reputation: 97
Joined: 14 Jul 2007 Posts: 3321
|
Posted: Fri Aug 07, 2020 2:22 pm Post subject: |
|
|
ParkourPenguin wrote: |
Csimbi wrote: | This is just a code that checks for specific keys every now and then. | That's actually kind of how hotkeys work in CE's source, but CE does it far more efficiently. |
Good to know, thanks!
Yup, GetAsyncKeyState is cheap (CPU-wise).
|
|
Back to top |
|
 |
|