| View previous topic :: View next topic |
| Author |
Message |
LostInTransliteration Newbie cheater
Reputation: 0
Joined: 25 Aug 2021 Posts: 10
|
Posted: Sat Jan 15, 2022 9:32 am Post subject: Checking for key presses |
|
|
I'm working on a script that overwrites normal camera controls. Currently to check for key presses while the script is active, I have a timer running that checks for key presses like this:
| Code: |
tflycam = createTimer(nil, false)
tflycam.Interval = 100
tflycam.Enabled = false
tflycam.OnTimer = function(flycamfunct)
-----------------------------------------
if (isKeyPressed(VK_W)) then
writeFloat(cameraX,readFloat(cameraX)+1) --//actual calculations abridged in this post for readability
end
if (isKeyPressed(VK_S)) then
writeFloat(cameraX,readFloat(cameraX)-1) --//actual calculations abridged in this post for readability
end
--//and so on for all other hotkeys in use in this flycam
-----------------------------------------
end
|
But there's gotta be a smarter way to do this that isn't just a dozen "if ... then" checks every 100 ticks. What's a better way to do this?
|
|
| Back to top |
|
 |
Frouk Grandmaster Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 514
|
Posted: Sat Jan 15, 2022 10:22 am Post subject: |
|
|
i guess its not(since script will write camera x always when key is pressed)
not topic related:
From your syntax i see that you are c++,c# coder
|
|
| Back to top |
|
 |
TheyCallMeTim13 Wiki Contributor
Reputation: 51
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Sat Jan 15, 2022 10:24 am Post subject: |
|
|
Never really messed with it, but from the "celua.txt" file.
| Code: |
GenericHotkey Class : (Inheritance: Object)
createHotkey(function, keys, ...) : returns an initialized GenericHotkey class object. Maximum of 5 keys
createHotkey(function, {keys, ...}) : ^
properties
DelayBetweenActivate: integer - Interval in milliseconds that determines the minimum time between hotkey activations. If 0, the global delay is used
onHotkey: The function to call when the hotkey is pressed
methods
getKeys()
setKeys(key, ....)
setOnHotkey(table)
getOnHotkey |
But yeah the options for what you want kind of thing seem limited; it's either hotkey, timer, or thread.
_________________
|
|
| Back to top |
|
 |
|