LostInTransliteration How do I cheat? Reputation: 0
Joined: 25 Aug 2021 Posts: 9
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?
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 _________________
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
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