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 


CE Make Hotkeys more responsive

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Meiyoh
Master Cheater
Reputation: 1

Joined: 14 Mar 2015
Posts: 402

PostPosted: Fri Aug 07, 2020 2:47 am    Post subject: CE Make Hotkeys more responsive Reply with quote

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
View user's profile Send private message
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3321

PostPosted: Fri Aug 07, 2020 12:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
Meiyoh
Master Cheater
Reputation: 1

Joined: 14 Mar 2015
Posts: 402

PostPosted: Fri Aug 07, 2020 2:04 pm    Post subject: Reply with quote

Csimbi wrote:
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?).


i believe the issues is with the way i use things . Since Counter is not reliable and the readFloat/WriteFloat part is the counter. DaSpammer suggested a better approach with os.clock instead but i will have to find how to use os clock instead of counter to delay then do stuff

Thanks for the reply Very Happy

_________________
I am the forgotten one the dead one.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4700

PostPosted: Fri Aug 07, 2020 2:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3321

PostPosted: Fri Aug 07, 2020 2:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites