Skip to content

Writing Aliases

Andreas Schneider edited this page Aug 11, 2018 · 4 revisions

Alias syntax

Regular alias:

alias "command" "arg1;arg2 var;argN"

Note: It's not possible to pass more than 2 arguments/variables per semi-colons, the following will not work:

alias stuff "bind x fps_max 20"

The workaround is to create an alias for "fps_max 20":

alias fps20 "fps_max 20"
alias stuff "bind x fps20"

+ and - command alias:

When a key is pressed, +command is called, and when released, -command.

alias +command "arg1;arg2 var;argN"
alias -command "arg3;argN"

Simple key-hold script for switching fps_max:

alias +fps20 "fps_max 20"
alias -fps20 "fps_max 100"
bind z +fps20

Note: All -command aliases are called (alongside with any -keybind) when the menu is open OR a save is loaded.

Looping alias

bxt_append currently allows custom command names whereas special and cmd are tied to _special and name respectively.

Bunnymod XT style

alias mainloop "arg1;arg2 var;bxt_append _command"
alias +script "alias _command mainloop;mainloop"
alias -script "alias _command"

Half-Life (1998-2002) cmd

alias mainloop "arg1;arg2 var;cmd name"
alias +script "alias name mainloop;mainloop"
alias -script "alias name"

Half-Life (2003-2009) special

alias mainloop "arg1;arg2 var;special"
alias +script "alias _special mainloop;mainloop"
alias -script "alias _special"

Nested aliases

TODO
Take a look at the main page and check how the bunnyhop looping script works in steps, in a way that it freely allows user inputs between +jump/wait/-jump/wait. Jumpbug scripts are basically a long chain of waits that serve as a way for timing -duck;+jump at the right frame.

Some command definitions TODO

wait - stops command parsing until the next frame.
alias <command> - defines a new command.
alias - prints all defined aliases.
cl_pitchup - max angle for looking up.
cl_pitchdown - max angle for looking down.
fps_max - limits frame-rate, values are 4-byte float precise.
spk or speak - plays .wav files from the "sounds" folder. It's possible to chain files together using a comma ".".

Further reading https://www.l4dnation.com/wiki/Scripting