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 properly put combined hotkeys to isKeyPressed?

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

Joined: 15 Feb 2017
Posts: 11

PostPosted: Mon Sep 25, 2017 8:49 pm    Post subject: How properly put combined hotkeys to isKeyPressed? Reply with quote

Hi!
I try to make my first fly camera cheat and of course stuck with one problem.

So here is sample part of current code, which work as it should. "Base" was founded on this forum, but i play a bit with it and get to understand some basics:
Code:

[ENABLE]
{$lua}
function checkKeys(timer)
  if (isKeyPressed(VK_W)) then  -- move Forward
    writeFloat("[[theHunterCotW_F.exe+01E62750]+E0]+150", 1)
  elseif (isKeyPressed(VK_S)) then  -- move Back
    writeFloat("[[theHunterCotW_F.exe+01E62750]+E0]+150", -1)
  else  -- if not used than don't move
    writeFloat("[[theHunterCotW_F.exe+01E62750]+E0]+150", 0)
  end
end

t=createTimer(nil)
timer_setInterval(t, 50)
timer_onTimer(t, checkKeys)
timer_setEnabled(t, true)

[DISABLE]

timer_setEnabled(t, false)


This values control player speed and while "W" or "S" key pressed - player move forward or back with "1" speed. Perfect. But what if i want send value "5" when i use "Shift+W" or any other combined keys? How should it be coded in such case?

I mean i can't figure out what should i type here in such case in "isKeyPressed"? Because isKeyPressed(VK_LSHIFT, VK_W) or isKeyPressed(VK_SHIFT, VK_W) doesn't work.

Probably i should use somehow createHotkey(FastForward, VK_SHIFT, VK_W) ? But i can't figure it out or find any readable for newbie like me (i mean all cheat tables with LUA free camera, that i can find, is pretty complex) any example of existing script where something same was already done.

I check main.lua, virtual key codes and read a lot of threads here from google, but anyway no have idea what should i do :/


Last edited by geesve on Tue Sep 26, 2017 7:57 am; edited 2 times in total
Back to top
View user's profile Send private message
ParkourPenguin
Grandmaster Cheater Supreme
Reputation: 54

Joined: 06 Jul 2014
Posts: 1815
Location: Arcadian Suburbia

PostPosted: Mon Sep 25, 2017 9:03 pm    Post subject: Reply with quote

This is the first thing I thought of off the top of my head:
Code:
if isKeyPressed(VK_W) and isKeyPressed(VK_SHIFT) then
  print('yes')
end

_________________
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
geesve
Newbie cheater
Reputation: 0

Joined: 15 Feb 2017
Posts: 11

PostPosted: Mon Sep 25, 2017 9:21 pm    Post subject: Reply with quote

ParkourPenguin wrote:
This is the first thing I thought of off the top of my head:
Code:
if isKeyPressed(VK_W) and isKeyPressed(VK_SHIFT) then
  print('yes')
end


Wow.. I was scared that possible solution, probably, will required bigger amount of code and logic, but... Such simple and works perfect! Smile
Thank you a lot!
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 120

Joined: 09 Jun 2013
Posts: 3260

PostPosted: Thu Sep 28, 2017 2:29 pm    Post subject: Reply with quote

Code:
function areKeysPressed(...)
  for i, v in ipairs({...}) do
    if isKeyPressed(v) == false then
      return false
    end
  end
  return true
end
if areKeysPressed(VK_SHIFT, VK_W) then
  print("yes")
end
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