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 


how do I set a hotkey that executes my lua code?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
LastExceed
Expert Cheater
Reputation: 1

Joined: 05 Nov 2014
Posts: 130

PostPosted: Thu Aug 27, 2015 10:49 am    Post subject: how do I set a hotkey that executes my lua code? Reply with quote

I actually feel embarrased asking something basic like this, but all I want to do is create a trainer that simply executes my code as soon as I press a specific hotkey. The trainer needn't look any good, default layout from
file -> Generate generic trainer lua script form table is enough.

I know, I know, there are millions of tutorials already and it's absolutely unnecessary to create a new thread for this, but whenever I try to find an answer to even the most dumpest questions, I only find tutorials for way too advanced stuff instead of the simple answer I was looking for...
Back to top
View user's profile Send private message
Smellyhobo101
Newbie cheater
Reputation: 0

Joined: 21 Sep 2014
Posts: 23

PostPosted: Sun Aug 30, 2015 4:14 pm    Post subject: Reply with quote

Set up a timer to call a function. Then use an if statement with the isKeyPressed(key) function to check if the key has been pressed. "key" is a virtual-key code. You can google a full list of them.

Code:

function main()
if isKeyPressed(VK_A) then
--Put your code here
end
end

t = createTimer(nil, false)  -- create a Timer object and assign it to variable t
timer_onTimer(t, main)   -- When the timer ticks, call the function main
timer_setInterval(t, 50) -- Sets the tickrate of the timer in milliseconds
timer_setEnabled(t, true) -- Turns the timer on
Back to top
View user's profile Send private message
LastExceed
Expert Cheater
Reputation: 1

Joined: 05 Nov 2014
Posts: 130

PostPosted: Mon Aug 31, 2015 11:16 am    Post subject: Reply with quote

Thanks a lot.
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