[LIB] Hotkeys with double click / multiple functions
Posted: Fri, 5. Sep 08, 16:58
Download file contains versions for both Reunion and Terran Conflict.
Scripters have been doing a good job of conserving command slots (for obvious reasons =) but several scripts use a bucketload of hotkeys instead of grouping several functions, that thematically belong together, onto one hotkey.
Scripts can get a lot easier to use if you only need one hotkey for a group of features instead of several.
(Select weapon config 1, Save weapon config 1.... could be single and double click of the same key.)
That's a lot easier to remember and seldom used functions can be put on a double or triple click layer, freeing up keys on the already cramped keyboard.
I wrote this library for my [SCR] Target Lock Hotkey when it got messy to add one more function to my "hardcoded" hotkey script, that had 3 functions per hotkey at the time.
Now this library supports an infinite number of hotkeys, each with an infinite number of keypresses.
Why only double click when you can quad click?
[ external image ] Download (ZIP)
Now it is that easy to let one hotkey do 2 completely different things:
Line 001 is the easiest and most maintainance free way of generating a solid identifier for a hotkey script.
There are other ways but this one always works. =)
Scripters have been doing a good job of conserving command slots (for obvious reasons =) but several scripts use a bucketload of hotkeys instead of grouping several functions, that thematically belong together, onto one hotkey.
Scripts can get a lot easier to use if you only need one hotkey for a group of features instead of several.
(Select weapon config 1, Save weapon config 1.... could be single and double click of the same key.)
That's a lot easier to remember and seldom used functions can be put on a double or triple click layer, freeing up keys on the already cramped keyboard.
I wrote this library for my [SCR] Target Lock Hotkey when it got messy to add one more function to my "hardcoded" hotkey script, that had 3 functions per hotkey at the time.
Now this library supports an infinite number of hotkeys, each with an infinite number of keypresses.
Why only double click when you can quad click?
[ external image ] Download (ZIP)
Now it is that easy to let one hotkey do 2 completely different things:
Code: Select all
001 $HK.Name = get script name
002 @ $Nr.of.clicks = $Null -> call script 'lib.gz.multi.hotkey' : hotkey name=$HK.Name keypress delay=400
003
004 if $Nr.of.clicks == null
005 return null
006
007 else if $Nr.of.clicks == 1
008 $Target = get player tracking aim
009 $Target -> destruct: show no explosion=null
010
011 else if $Nr.of.clicks == 2
012 [PLAYERSHIP] -> destruct: show no explosion=null
013
014 end
015 return null
There are other ways but this one always works. =)