24 Feb 11, 08:49AM
Rather complicated one today...
But it cleans up nicely when I apply it to a concept like this:
Now hotkeys just became a reality! :D
[SELECT ALL] Code:
// ifbind -- encase an already-existing keybind in a conditional statement -- by V-Man
alias ifbind [
bind $arg1 (concat [if] $arg2 (concatword "[" (if $arg4 [result (keybind $arg1)] [result $arg3]) "]") (concatword "[" (if $arg4 [result $arg3] [result (keybind $arg1)]) "]"))]
// ifbind (key) (condition) (command) (Use normal keybind if condition is 1 or 0?)
// ifbind C [$ctr] [domodifier 2] 1
// Takes the current bind in key "C" and makes it the "if yes" (1) argument in an encasing "if" statement depending on $ctr (thus, the provided command is executed when $ctr evaluates to 0).
// ifbind V [$connected] [showmenu voicecom] 0
// Takes the current bind in key "V" and makes it the "if not" (0) argument in an encasing "if" statement depending on $connected (thus, the provided command is executed when $connected evaluates to 1).
But it cleans up nicely when I apply it to a concept like this:
[SELECT ALL] Code:
add2bind LCTRL [ctr = 1; onrelease [ctr = 0]]
add2bind RCTRL [ctr = 1; onrelease [ctr = 0]]
add2conloop [if (strcmp $conline [ ]) [] [cconline = $conline]]
alias hotkey [ifbind $arg1 [$ctr] $arg2 0]
hotkey C [if $editing [copy] [copyconline = $cconline]]
hotkey V [if $editing [paste] [saycommand (getalias copyconline)]]
hotkey A [if $editing [select 2 2 512 512] []]
hotkey S [if $editing [if (strcmp (curmap) []) [saycommand [/savemap ]] [savemap]] []]
hotkey Z [if $editing [undo] [suicide]]
hotkey F [saycommand [/docfind ]]
hotkey Q [quit]
hotkey P [screenshot]
hotkey O [if $connected [showmenu Gamemode] [showmenu maps]]
// Add more hotkeys as you wish! Any key pressed at the same time as a CTRL button will essentially have a different bind, practically doubling your keyboard space!