Joined: 08 May 2017 Posts: 14 Location: I don't exist... Unfortunately
Posted: Wed May 10, 2017 7:41 am Post subject: Making hotkey that reverts to initial value when not pressed
Essentially, I want a simple CE hotkey to change a value ( let's say gravity) to 15 then revert it to -40 once the key is no longer held down. Do I need to script this, or is there a way to do it in the CE settings. PS: I know this should be obvious but my brain is not working. _________________
Um... Hello... Thanks for taking the time to read my pointless signature
Hm.... not sure of anyway to do it without a script but the script itself is simple enough. There are of course different ways to do it but here's one using 2 hotkeys so that only the functionality is coded in the script and the actual action/values are in the hotkeys (note: the one you want to hold down should be first and the second, the one that reverts the value, doesn't need any keys set since it'll be activated by code when you release the first key of the hotkey combo)
Code:
-- code to find the hotkeys
al = getAddressList()
mr = al.getMemoryRecordByDescription("Name of record with hotkeys")
-- get hotkeys, based on position in list aka index not ID (at least fairly sure it's index)
hk = mr.Hotkey[0]
-- set a function to run the second hotkey after the first has run
-- and the first key has been released
hk.onPostHotKey = function(sender)
timer = createTimer()
timer.Interval = 100 -- check every 100 milliseconds
timer.OnTimer = function(timer)
if not isKeyPressed(hk.keys[1]) then
sender.Owner.Hotkey[1].doHotkey()
timer.destroy()
end
end
end
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