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 


Lua - how do you check the state of a key press each 'frame'

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
thebmxbandit11
Newbie cheater
Reputation: 0

Joined: 03 Jul 2014
Posts: 15

PostPosted: Thu Nov 20, 2014 12:20 am    Post subject: Lua - how do you check the state of a key press each 'frame' Reply with quote

I want to set a value in memory like this:

Code:

   if X key was just pressed

        set a = 0

   if X key was just released

        set a = 1


also is there just a way in lua that you can have a function that doesn't require a hotkey to run, as in its just called every frame no matter if there is a button pressed down or not?

Thanks!
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Thu Nov 20, 2014 1:21 am    Post subject: Reply with quote

Cheat Engine offers the following key functions:
Code:
isKeyPressed(key) : returns true if the specified key is currently pressed
keyDown(key) : causes the key to go into down state
keyUp(key) :causes the key to go up
doKeyPress(key) : simmulates a key press


With that, you could create a timer and keep checking isKeyPressed. You can store the state of the key to determine if it is up/down to monitor for pressed and released like you want too.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
thebmxbandit11
Newbie cheater
Reputation: 0

Joined: 03 Jul 2014
Posts: 15

PostPosted: Thu Nov 20, 2014 8:44 pm    Post subject: Reply with quote

atom0s wrote:
Cheat Engine offers the following key functions:
Code:
isKeyPressed(key) : returns true if the specified key is currently pressed
keyDown(key) : causes the key to go into down state
keyUp(key) :causes the key to go up
doKeyPress(key) : simmulates a key press


With that, you could create a timer and keep checking isKeyPressed. You can store the state of the key to determine if it is up/down to monitor for pressed and released like you want too.


I was unaware of "Timer" thank you this works perfectly Smile
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 Lua Scripting 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