Mega Man 8-bit Deathmatch > Tutorial Collection

[GUIDE] Guide to the Console!

(1/4) > >>

King Dumb:
Table of Contents[/size]

**Throughout this guide, parameters to CVARs and CCMDs will be surrounded by brackets [ ] when they are introduced. These brackets are not included when using the actual CVARs and CCMDs.**

I. Introduction to the Console
        --------A. What is the console?
        --------B. CCMD vs. CVAR
II. Commonly Encountered CCMDs and CVARs
        --------A. CCMDs
        --------B. CVARs
III. Bind, Doublebind, and Rebind
   --------A. Bind
   --------B. Doublebind
   --------C. Rebind
IV. The Configuration File, Autoexec.cfg, and Atexit
--------A. The Configuration File
--------B. Autoexec.cfg
--------C. Atexit
V. Creating CVARs
VI. Wait, Eval, Test, and Exec
   --------A. Wait
   --------B. Eval
   --------C. Test
   --------D. Exec
VII. Alias
   --------A. Introduction
   --------B. Examples
IX. Tips and FAQ
--------A. More Helpful Tips
--------B. FAQ


I. Introduction to the Console

A. What is the console?

The console is the interface via which players (clients) interact with the game engine to alter settings, configurations, etc. By default, the console is opened by pressing the ` key. This opens a blue box that contains messages and console input history and, essentially, a command line. It is from here that the client types and enters all console inputs, which come in the form of Console Commands (CCMDs) and Console Variable (CVARs).


Every input that clients make into the console is in the form of a Console Command (CCMD) or a configuration of a Console Variable (CVAR). There is no setting in the console you must toggle to switch between the two; it all depends on what you input into the command line.

The most important difference between CVARs and CCMDs is that CVARs generally control settings while CCMDs will perform actions or functions for you. Things such as display settings, player name, class, and skin, server settings, and renderer options are controlled by CVARs. As such, every CVAR, when input into the console, will have both its name and a parameter. The name determines what setting will be changed, and the parameter, of course, determines what the setting will be changed to. Every parameter falls into one of a few categories:

Boolean - The simplest kind of CVAR. Boolean CVARs operate on a simple true/false, yes/no basis. As such, these CVARs are entered into the console as [name] [true/false] or just [name] [1/0].

Integer - These CVARs deal with settings that can hold any value in a range of integers. They are entered as [name] [integer].

Float - Very similar to integer CVARs, except these operate with numbers with decimals. The input is [name] [number].

String - Some CVARs operate using string parameters. A string is simply a line of text, surrounded by quotes if it is more than one word. For examples, "Hello world!" is a string. Many CCMDs require parameters involving specific strings, such as changemus.

Color - A few CVARs deal with color-based settings, and so their parameter is in the form of a color code, such as ff 00 00. Color-based CVARs can also operate with several shorthand parameters, in the form of simple color names like "blue".

Inputting a CVAR name into the console without a parameter will print the CVAR's current value in the console.

On the other hand, CCMDs can often operate without parameters, because they perform a function or action. Some CCMDs do require or support the use of parameters; these CCMDs often perform a function that slightly varies based on the parameter(s) given. Player movement, for example, is executed via CCMDs.

There is one special kind of CCMD, called action commands. These are most heavily used for player movement. You can tell if a CCMD is an action command if the name of command begins with a +. Commands beginning with a +, such as +jump, have counterpart commands, which are identical in name except for the fact that they begin with a - instead. These commands are special in that whatever the + version does when it is executed, the - command stops. The special property that makes these commands work is that when a key is pressed that activates a + command, the - command is automatically executed when that key is released. In other words, when you press your jump button, the command +jump is executed; this command makes you continually jump. When you release your jump button, the command -jump is executed, which stops the jumping. All movement commands work like this.

II. Commonly Encountered CVARs and CCMDs.[/size]

Please note that the following lists are not complete, but merely serve as a brief introduction to the more commonly used CVARs and CCMDs. For more complete lists, please direct your attention to the ZDoom Wiki or the Zandronum Wiki.


(click to show/hide)Note: While your gameplay is affected by dozens and dozens of CVARs, I will be covering here only those that are usefully accessible by the client, not the server.

chat_substitution (Boolean) - Turns chat substitution on or off. When on, the following substitutions are made within the 'say' command (when chatting):
   $health displays your current health
   $weapon displays your current weapon
   $ammo displays your current ammo type (will basically be [weapon]ammo)
   $ammocount displays your current ammo count
   $armor displays current armor
**Note: The above replacements are not treated as CVARs nor as integers, so you can't perform operations with them. Sorry!**
cl_run (Boolean) - When on, the player will always run rather than walk (this should    always be on).
freelook (Boolean) - When on, you can use the mouse to look all around you, all    direction. (This should always be on, too).
name [name] (String) - The player's name.
skin [skin] (String) - The player's skin.
cl_capfps (Boolean) - If true caps your FPS at 35.
chase_height [height] (Integer) - Adjusts the height of the chasecam above the player.
chase_dist [distance] (Integer) - How the chasecam is behind the player.
autoaim [integer] (Integer) - Determines the minimum vertical distace the player's sights must be to autoaim. Maximum of 5000 for original Doom behaviour of always    autoaiming.
playerclass [class] (String) - The player's class.
movebob [movebob value] (Float) - Determines how much the player's view bobs when running.
chatmacro[number 0-9] (String) - Chatmacros are messages built into the game engine, and there are 10 of them, starting with cahtmacro0 all the way to chatmacro9. Each stores a string that can be said automatically as if it were typed by you by pressing the 'say' button (default to t), then holding ALT and hitting the number key corresponding to the chatmacro you wish to say. Here are the defaults:
chatmacro0: "No"
chatmacro1: "I'm ready to kick butt!"
chatmacro2: "I'm OK."
chatmacro3: "I'm not looking too good!"
chatmacro4: "Help!"
chatmacro5: "You suck!"
chatmacro6: "Next time, scumbag..."
chatmacro7: "Come here!"
chatmacro8: "I'll take care of it."
chatmacro9: "Yes."
To automatically say "Come here!", for example, you'd press t, then hold ALT and press 7. The strings inside each chatmacro can be changed like normal CVARs. Each chatmacro is one individual CVAR.
team [team number] (Integer) - Specifies the player's team for team games. 1 is blue (Dr. Light) and 2 is red (Dr. Wily). Setting the value to 255 is the same as auto-selecting a team (ie, based on current team sizes).

(click to show/hide)+forward - Moves the player forward.
+back - Moves the player backward.
+moveright - Moves the player to the right.
+moveleft - Moves the player to the left.
+right - Turns the player to the right.
+left - Turns the player to the left.
+strafe - Causes mouse movement to make the player move right and left rather than turn.
+jump - Causes the player to jump.
toggleconsole - Makes the console appear.
+showscores - Makes the scores overlay appear.
weapnext - Switches to the next weapon.
weapprev - Switches to the previous weapon.
invuse - Uses the currently selected inventory item.
invnext - Scrolls to the next inventory item.
invprev - Scrolls to the previous inventory item.
+attack - Causes the player to attack (shoot).
+altattack - Causes the player to use an alt attack (altfire).
say [string] - Makes the player say [string] in the chat.
say_team [string] - Makes the player say [string] in the team chat.
spectate - Makes the player spectate from the current game.
changemus [music name] - Changes the music to [music name].
callvote [vote type] [new value] - Calls a vote of [vote type] to be changed to [new value].
   For example, callvote changemap mm1cut.
turn180 - Turns the player around 180 degrees pretty fast.
centerview - Immediately levels your view to straight ahead (levels your view vertically).
use [weapon name] - Switches to weapon of name [weapon name] instantly. All weapon    names in MM8BDM are simply the weapon's actual name followed by 'wep'. So,    to switch to Gravity Hold, you'd type: use gravityholdwep.
slot [slot number] - Switches to the first weapon in the slot defined by [slot number].
+use - Not to be confused with use or invuse. This comman causes the player to do    specific actions, like open certain doors or activate switches. You won't use this    much in MM8BDM.
chase - Activates the chasecam, if sv_cheats or sv_chasecam are enabled.
logfile [location] (String) - When [location] is specified, including a name ending with .txt    at the end, the game will log the entire console into that file for later reading. If only    a location folder is specified, the game will log the console and give it an    automatically generated name based on the date and time. If no [location] parameter    is specified, the current logging will cease.
spynext - Sets your view to another player's first person view (continuing pressing this to scroll through everyone alive). Only usable as a spectator in non-team games. In team games, if you are alive, it works, but only on your team.
spyprev - Same as above, but scrolls through players in the reverse order.
III. Bind, Doublebind, and Rebind[/size]

This begins the important parts of this guide. Bind, doublebind, and rebind are all CCMDs involved with one very important task: assigning functions to keys. Every key that does something in-game when pressed has a function bound to it. These are the commands that are assign an action to a key.

A. Bind

(click to show/hide)We'll start with the simplest of the three: the bind command. Here is the syntax of the bind command:

bind [key] [function]

Pretty simple. For example, if you want to make a key make you jump when you press it, you would do this. Let's say we want the G key to make us jump.

bind g +jump

After you enter that, pressing g will cause you to jump, and releasing it will stop you (binding a key to an action command will automatically make the - counterpart activate upon release, so don't worry about that).

You can bind a key to literally anything you want; that is, any CCMD. You can also bind a key to change a CVAR.

Now, there quite a number of rules to follow when binding keys. The syntax order always remains the same. When the [function] parameter is complex, it's best to use quotes. When you have to embed quotes (say, you are binding a key to execute a command that requires a string), you must do it like this (for example, binding a key to change a name):

bind n "name "Apple Cider""

That may look a little complicated at first. Let's break it down. When changing the name CVAR, this is the syntax:

name [new name]

When your new name contains more than one word, you have to use quotes (as it is a string). So:

name "Apple Cider"

However, you have to include the entire above input phrase as a single parameter of the bind command. Because this phrase includes more than one item (it has "name" and "Apple Cider"), it needs its own quotes.  But you can't get rid of the quotes around "Apple Cider"! You have to embed the quotes around "Apple Cider". This is done by preceding each quote with a . Like this:

bind n "name "Apple Cider""

Hopefully this clears up embedding for the most part. Much later in the guide we'll deal with multiple layers of emebeddment.

While we're on the subject on binds, the bind command is how players can speak long lines of text instantly.

bind q "say "It's time""

Anothe very important thing to remember about binding is that more than one function can be bound to a key. This is achieved using quotes around the [function] parameter and by separating individual functions by a semicolon (;). For example:

bind 9 "+jump; +attack"

Pressing 9 would cause you to jump and shoot, and releasing 9 would stop both of these. You can add as many functions as you want.

When you edit controls via the menu, all you're doing is adjusting your binds! Using the bind command via the console is simply the more technical way, and really faster, too.
B. Doublebind

(click to show/hide)The doublebind command is identical to the bind command in syntax and almost identical in function. The only difference is that the doublebind command defines what occurs when a key is pressed twice is immediate succession.

doublebind u "say asdfghjkl"

Pressing u twice in succession will make you say "asdfghjkl". It's important to note that keys can have a bind and a doublebind on them. If that is the case, pressing the key twice will activate the bind of the first press, and the doublebind on the second press. While this can be useful, care must be taken. Binding and doublebinding a chat phrase to one key and using both will be considered chat spam by the server, and binding and doublebinding, for example, a name change and a skin change will be considered user info change flood and will result in a kick.
C. Rebind

(click to show/hide)This is by far the most advanced binding command, and truthfully one of the most advanced CCMDs period. The rebind command serves the same basic purpose as the bind commad: assigning a function to a key. The difference is that you can't just type a rebind command with parameters into the command line. The rebind command is special in that it can only be called (that is, executed) from within a command or series or commands. If you don't understand what I mean, just take a look at this example:

bind enter "invuse; rebind +jump"

So what does this mean? Enter this into the command line, then press enter once. It will make you use your selected inventory item. However, all subsequent presses of the enter key will cause you to jump. That's because the original binding included "rebind +jump". The rebind command can only be used like this. Now, some of you may already have noted the the above effect can also be achieved like this:

bind enter "invuse; bind enter +jump"

True, this would achieve the same effect. However, the one difference is that the rebind command requires no key parameter. That won't seem very important right now, but later we'll examine the uses of rebind.

Unfortunately, there is no doublebind version of the rebind command.
IV. The Configuration File; Autoexec.cfg, and Atexit[/size]

Here we will examine a few miscellanious functions that you'll need to know for the more advanced portions of the guide. But before that, I need to introduce to you a very important file.

A. The Configuration File

(click to show/hide)The configuration file is the file, automatically created by Zandronum, that holds of your settings; CVARs, binds, etc. It's what the game reads to know how to configure your player each time you open the game, and it's how your settings and binds save over from one session to another.

This file, which you can open in Notepad on Windows computers (Mac and Linux users should know what they should use, I don't), is located wherever zandronum.exe is located. The title of this file will be "zandronum-[Your Name].ini". Most often, you'll hear players (and I) refer to this file as the ini, .ini, or config file.

And yes, you can change change your settings/CVARs/etc from directly within the .ini, but make sure you save and don't have a game session open when you do!
B. Autoexec.cfg

(click to show/hide)The autoexec.cfg file is a file that you can create and define in your .ini file that will automatically execute as many console command lines as you want upon starting the game. These files are made using Notepad (plain text editor). From there, enter in lines of text that would normally enter straight into the console. Each line in the plain text editor can be treated as a line in the console, so go to town with semicolon and whatever. You can have as many lines as you want, and they will all be executed automatically and simultaneously upon entering the game.

Make sure the file type of autoexec is .cfg, not .txt, when you save it.

Now, the second step is to place your autoexec.cfg file wherever you want. It doesn't matter, as long as you know where it is. Then, open up your .ini file, and find the heading called [Doom.Autoexec]. Below that heading, type the "Path=" (without quotes) then the location of your autoexec file. For example, C:UsersMyNameDocumentsautoexec.cfg. Next, create a new heading called [Megaman.Autoexec], and put the location there as well. I do this because I can never tell which one it is that is working. Doesn't hurt to put both!
C. Atexit

(click to show/hide)Atexit is a CCMD with the following syntax:

atexit [command 1] [command 2] [command 3] ...

The parameters to atexit can be however few or many you wish, and each parameter is simply any command or CVAR change. What atexit does is cause these commands to automatically be executed everytime you exit the game. For example:

atexit "bind r +jump"

Will bind the r key to make you jump, every time you leave the game. Pretty cool! Entering atexit without parameters will show what commands are currently being executed at exit.
V. Creating CVARs

(click to show/hide)As a client you can create your own CVARs for your own use. Obviously, these won't be affecting gameplay or things like that, but they are values that you can use for various functions later on. Creating your own CVARs won't be of much use now, but we'll cover it now.

The set command is the primary command for making CVARs, with this syntax:

set [CVAR name] [value]

CVAR names may not have spaces in them. You don't have to specify what value type your CVAR is (Boolean, string, etc.). It won't really matter for user-created CVARs. The game will detect whether the CVAR stores a name or a number, however.

However, creating a CVAR using the set command will not save the CVAR for use in later settings. For that, you must use the command archivecvar. After you create the CVAR with the set command, do this:

archivecvar [CVAR name]

This will save the CVAR to your .ini for future use. To undefine a user-created server, use the unset command:

unset [CVAR name]
VI. Wait, Eval, Test, and Exec

This is the section where we begin examining the more versatile and powerful abilities of the console, in the form of some very useful CCMDs.

A. Wait

(click to show/hide)The wait command is a very simple one, but one that you will learn to value more than most others. The wait command is a CCMD that requires an integer parameter. This integer is inerpreted as the number of tics (a unit of time used by the game engine) that the wait command will... well, wait. That's right, all the wait command does is stall. As such, it does nothing when called by itself from the command line. It is, however, used in series of commands, and in binds. Take the following example:

bind alt "name "Apple Cider"; wait 35; say "I am Apple Cider!""

Pressing the alt key will change the player's name to Apple Cider, then make the player say "I am Apple Cider!" 35 tics later. There are 35 tics in one second. Waiting one tic will make the subsequent command happen almost instantly, but not technically so. This will be very useful later on.

Executing wait without a parameter will wait 1 tic.
B. Eval

(click to show/hide)Now things get complicated. The eval command gives you access to the game engine's computational abilities through the console. It is a calculator, but it is also so much more. It can perform computations with preset values (numbers), but also with variables. And of course, by variables, I am referring to CVARs! Remember, all CVARs are simply different values that can be changed; these values, of course, come in different types (Boolean, integer, float, string, color) that determine how they are interpreted, but they are all values nonetheless. The eval command lets the client perform computations with these variables, and then allows the results to be stored as values in CVARs.

This all sounds complicated, so let's start at the beginning.

The eval command can perform basic math, with the syntax:

eval [expression]

Entering the expression parameter can prove a little tricky at first, because the game engine uses a different notation for writing expressions than most are used to, called prefix notation. The operator is put before, not between, the operands. In other words, what we would write on paper as:

2 + 2

the game engine uses the form:

+ 2 2

Each symbol (numbers and operator) must be separated by a space. So, back to our CCMD:

eval + 2 2

Entering this into the command line will print the result in the console, so you'll see:

]eval + 2 2

Pretty cool, right? There are all kinds of operations that eval can perform. Here's a brief list:

+ a b
Adds a and b.
- a b
Subtracts b from a.
* a b
Multiplies a and b.
/ a b
Divides a by b.
% a b
Calculates the remainder of a/b.
^ a b
Raises a to the b-th power.
< a b
Gives a result of 1 if a is less than b and 0 if not.
<= a b
Gives a result of 1 if a is less than or equal to b and 0 if not.
> a b
Gives a result of 1 if a is greater than b and 0 if not.
>= a b
Gives a result of 1 if is greater than or equal to b and 0 if not.
= a b
Gives a result of 1 if a is equal to b and 0 if not.
== a b
Gives a result of 1 if a is equal to b and 0 if not.
!= a b
Gives a result of 1 if a is not equal to b and 0 if it is.
<> a b
Gives a result of 1 if a is not equal to b and 0 if it is.
xor a b
Calculates the bit-wise exclusive-or of a and b.
& a b
Calculates the bit-wise and of a and b.
! a b
Calculates the bit-wise or of a and b.
&& a b
Calculates the logical and of a and b.
|| a b
Calculates the logical or of a and b.

Those last five functions may seem foreign to you; that's okay. I will explain them at a later section, as they're not terribly useful with just the eval command.

In addition to printing results, the eval command can also store results in a CVAR. This is accomplished by adding an extra parameter:

eval [expression] [variable]

where [variable] is the CVAR to store the result in. This is going to become very useful later on, but for now let's just look at an example:

eval + 5 5 screenblocks

This will add  5 to 5 (to get 10) then store the result (the integer 10) into the CVAR screenblocks (which controls the size of the screen that is used to display the game). This feature of eval becomes a whole lot more important once we start using CVARs in [expression] to perform calculations with them.

The first rule of using CVARs in expressions, or any time you're performing calculations with CVAR values, is that you must prefix the CVAR names with $. So, say we wanted to increase the screenblocks by 1, whatever they are currently. We would enter in the console:

eval + 1 $screenblocks screenblocks

Just use the CVAR name (with the $ at the beginning) as you would a normal operand. You can perform eval commands with all CVAR operands and no normal numbers, of course. And of course, as eval is just a CCMD, we can make binds with it:

bind s "eval + 1 $screenblock screenblocks"

Don't forget, the eval command works for any kind of CVAR, not just number-based ones. For example, let's say we wanted to make a bind that adds the letter x to the beginning of the player name. We would do this:

bind j "eval + x $name name"

This performs the operation x+$name then stores the result in the CVAR name. Remember, when dealing with string-based CVARs the order of the operands will matter more, even in addition. If you wanted to add the x to the end of your name, for instance, you'd have to do this instead:

bind j "eval + $name x name"

I'll take this moment to address a small quirk of the eval command. Let's say you wanted to append an asterik * to the end of your name. You'd try this:

eval + $name * name

Entering this into the console, however, will give you two errors: missing argument for +, and missing argument for *. That's because the engine interpreted the * as a multiplier operator, and thought you were evaluating a complex expression. As such, it thought that the * was missing its operands and that the + had only one operand ($name). In order to make the engine interpret operators as just symbols, add a  right before the symbol, like this:

eval + $name * name

This works in a very tricky way. The game engine will not print the  symbol in the console nor in chat messages. However, it does detect it commands entered in the console. This is the same reason why the  symbol is used for embedding quotes within quotes.

Entering that should append an asterik to the end of your current name.

Now, at this time I would take some time to familiarise yourself with how eval works, specifically the syntax when using more than two operands and more than one operation. It can get pretty complicated, and it will get very complicated later in this guide.

The first rule to remember when inputting longer expressions is that each operator only deals with the next two operands. For example, enter the following into the console:

eval + 2 2 2

Instead of adding 2 and 2 and 2 and printing 6 in the console, the console will display a message "Unknown variable 2". That's because the + sign only operates with the first two 2s, and the third 2 is treated as the [variable] parameter of the CVAR command. If you wanted to perform this summation, you'd have to do this:

eval + + 2 2 2

Let's take a look at what's going on here. The eval command sees the first + sign, and knows that the next two items in the command will be the operands, and that these two operands should be added together. The engine then sees the second + sign. Because a + sign must always come with two operands, the engine knows the the first operand of the original + sign is itself an operation. So, the engine sees the first two 2s as the operands of the second + sign, and performs this addition. That is the engine processing the first operand of the original + sign. Next, it must process the second operand, which is just another 2. It adds the two operands, which are 4 and 2, to print 6.

Another way to write this is:

eval + 2 + 2 2

which simply switches the order of the operands (because this is addition, the order of the operands doesn't matter due to the commutative property).
C. Test

(click to show/hide)The test command is the big brother of the eval command. It's everything that the eval command wants to be: as powerful, but also much more useful!

The test command works two ways: on a true/false basis and an expression basis. We'll cover the equality basis first, as that is more similar to the eval command. Here's the syntax:

test [expression] [true command] [false command]

The test command evaluates [expression] and then subsequently executes [true command] if the result is nonzero and [false command] if it is. However, [expression] can also be a complete equation (with something on both sides of the equals sign, or inequality sign if used instead). If that is the case, then [true command] is executed if the expression is true and [false command] is executed if the expression is false. Let's look at some examples:

test + 2 2 "+jump" "+attack"

Entering this will cause the player to start jumping, because 2+2=4 and 4=/=0.

test - 2 2 "+jump" "+attack"

Entering this will cause the player to start shooting, because 2-2=0.

test = 2 3 "+jump" "+attack"

This will cause the player to start shooting, because 2=/=3.

test = + 2 2 4 "+jump" "+attack"

This will cause the player to start jumping, because 2+2=4.

test = + 2 2 + 3 2 "+jump" "+attack"

This causes the player to start shooting, because 2+2=/=3+2.

test = $name "Apple Cider" "+jump" "+attack"

This will make you start jumping if your name is "Apple Cider" and start shooting if not.

Another very important thing to know about the test command (and leading into its true/false function): results of 1 (as well as all other numerical values that are not 0) are treated as true, and execute [true command], while results of 0 are treated as false, and execute [false command]. This means quite a few things. It makes the test command very easy to use with Boolean (true/false) CVARs, such as sv_infiniteammo:

test $sv_infiniteammo "+attack" "+jump"

If sv_infiniteammo is true, you will start shooting; if it isn't, you'll start jumping. Remember, if you use CVARs in the test command without operators like this, you still need the $ sign.

test $sv_fastweapons "+attack" "+jump"

If sv_fastweapons is on at all (it can be either 1 or 2), you will start shooting.

test = $sv_fastweapons 1 "+attack" "+jump"

In this case, however, you will only start shooting if sv_fastweapons is exactly 1.

It should be noted that you don't have to specify a [false command], if you don't want/need to. However, you can't have a false command without a true one, though you can always make the true command just a pair of empty quotes.

And of course, the [true command] and [false command] can be complex in and of themselves, with wait times, semicolons, and even additional tests and evals! If you do embed tests within tests, remember to be careful about your quote embedding. Anything within quotes that requires additional quotes itself needs those  symbols.

Now, earlier, in the eval section, there were 5 operations at the end of the list that probably looked foreign. Here they are again:

xor a b
Calculates the bit-wise exclusive-or of a and b.
& a b
Calculates the bit-wise and of a and b.
! a b
Calculates the bit-wise or of a and b.
&& a b
Calculates the logical and of a and b.
|| a b
Calculates the logical or of a and b.

The first three, the bit-wise operations, will be of little to no value for most people reading this thread. They perform operations bit-wise, meaning in binary. So far, I haven't found a use for them when something else wouldn't suffice, and be easier at that (except one use, that is).

The last two, however, are important. The logical and operator (&&) will result in a 1 if BOTH of its operands are nonzero/if they are both true, and will result in a 0 if AT LEAST ONE operand is zero/false.

The logical or operator (||) will result in a 1 if EITHER or BOTH of its operands are nonzero/true, and will result in a 0 if BOTH are zero/false.
D. Exec

(click to show/hide)The exec command is much simpler than the eval and test commands, but very important once you start getting more usage out of those two. The exec command works like this:

exec [file location]

All the exec command does is execute a .cfg file. The [file location] is the full location, including name and .cfg suffix, such as

exec C:ExecFoldertestexec.cfg

The .cfg files that the exec command uses are just additional files you make that are identical in syntax to the autoexec.cfg file; that is, just use them like multiple lines of the console. This is useful when you often need to perform a lot of commands at once that are difficult to bind to a key , type in the console, embed, etc.; you won't have to worry about those things nearly as much when using  .cfg files and the exec command to do the long tasks.
VII. Alias[/size]

A. Introduction

(click to show/hide)Here we are; the moment we've all been waiting for. Up until now you've been learning the tools of the trade: here is the trade itself, in the form of the most versatile CCMD in the engine: the alias command. Here is the syntax:

alias [command name] [string of commands]

The alias command has an essentially simple function: it creates new CCMDs. The parameter [command name] is the name of your new command (may not have spaces) and [string of commands] is what your new command does. The second parameter may be simple, long, complex, short, etc etc etc. Anything you want, really.

Typing in just alias [command name] into the console will delete the alias with name [command name] from your configurations.

Here are a few basic tricks we'll be using with aliases.

Aliases can be used to turn action commands (+/- commands) into normal commands. Essentially, this turns action commands into toggles, like this:

alias runforever "+forward"

Executing runforever will then make the player constantly move forward. This is because the engine does not check within the actual alias to see if it should execute - commands. In fact, the engine will not check within any CCMD for embedded action commands. This is why, when we were doing tests with +jump and +attack, you continuously jumped or shot, without stopping, until you press Esc.

Conversely, you can create action commands with alias, like this:

alias +quickconsole "toggleconsole"
alias -quickconsole "toggleconsole"

Whenever you make new action commands, be sure to define both the + and minus versions. And, while the + and - versions don't have to simply be the opposites of each other (you can have the - version do something else, for example), it is a good idea to make sure the - command undoes things like movement that the + command initiates. Anyway, the above example makes a command that lets you open the console by holding a key, and close it by releasing it.

That being said, remember that you can bind keys to execute aliases, too.

bind c "+quickconsole"

Aliases can be recursive; that is, they can call themselves. Like this:

alias autoshoot "+attack; wait 35; -attack; wait 1; autoshoot"

This alias will make you attack for 1 second, stop, then (almost) immediately start up again, and keep doing so. Be careful with recursive aliases: they can only be stopped by pausing/opening the game menu or by undefining the alias. A more controlled way to use recursive aliases is with the test command; you can use it to check if some condition is met, and then stop the recursion if you want. Like this:

alias autoshoot "+attack; wait 35; -attack; test $sv_infiniteammo "autoshoot""

This version of our autoshoot command will only recurse if you still have infinite ammo.

And of course, aliases can include other aliases!

Another very important property of the alias command is its ability to make commands that use parameters.

alias assault "+attack; wait %1; -attack"

What we're looking at here is of course that %1. This a way to refer to the first parameter given when the command assault is executed. For example:

bind k "assault 1000"

Hitting k will cause the player to shoot for 1000 tics, then stop. You can add as many parameters as you want:

alias assault "+attack; wait %1; -attack; wait %2; +attack; wait %3; -attack"

Just like that! Also note that %0 refers back to the command name itself. This one won't be terribly useful, but it can have uses when you have lots of aliases doing similar things.
B. Examples and Useful Aliases

(click to show/hide)The best way to demonstrate what you can do with aliases is by providing you with a ton of functional examples! They'll get more complicated as we go on, but each one is (in some way) usable! Along the way I'll be revealing more helpful tricks about aliases, too.

Toggling The Scores Screen

alias scoreson "+showscores, rebind scoresoff"
alias scoresoff "-showscores, rebind scoreson"
bind [whatever key you want] scoreson

Here's rebind again! Executing scoreson will bring the scores screen up, and keep it up once you release the button. The scoreson alias will automatically rebind whatever key you used to scoresoff, so the next time you press that same key, you will bring the scores down; this, in turn, will rebind the same key to scoreson again. This demonstrates why the rebind command's ability to operate without a specified key parameter is useful. Whenever you want to change the key you use to show scores, you don't have to change the aliases!

More Efficient Tank Usage

This is one that I personally use quite often. At it core, this will binding using a W-Tank to a key, then doublebinding using an E-Tank to the same key. However, if you do this normally and want to use the E-Tank, you'll wind up using the W-Tank too; this way allows you to avoid that! This also shows how aliases can be used more liberally; that is, the entire definition process is done within a bind!

bind [key] "alias tankuse "use wtank"; wait 18; tankuse"
doublebind [same key] "alias tankuse "use etank""

Pressing the key once will use a W-Tank after an 18 tic (half second) delay - not too long. However, the second press when done in succession will change the alias to using the E-Tank, so once the alias activates from the first keypress, it will be using the E-Tank instead.

A good piece of knowledge to gain here: it takes pretty darn close to 18 tics to do that second keypress immediately after the first. When you're using this alias or others like it, use that as a rule of thumb.

Rapid Firing Chargeable Weapons

This is a series of simple aliases that accomplish a somewhat gimmicky but potentially useful goal: firing off uncharged shots of chargeable weapons easily by simply holding a button.

alias +rapidfire "alias intrapidfire "+attack; wait 1; -attack; wait 1; intrapidfire"; intrapidfire"
alias -rapidfire "alias intrapidfire"
bind [whatever key] +rapidfire

This doesn't actually make you fire more rapidly than you'd be able to otherwise, it simply makes it easier. The internal alias (intrapidfire) very quickly alternates between +attack and -attack to simulate simply holding +attack, but actually avoiding triggering charging. The +/- aliases are used to stop the cycle when you release the key, by undefining the internal alias in the - command.

The above can also be easily adapted into a series that allows you to hold a jump key and do short hops, which can be useful at times.

Credit goes to Jaxof7 for the premise of the above.

Random Number Generator

The following constitute a console-driven RNG.

alias rand_seed_establish "test >= $rand_seed_lo 1 "alias rand_seed_establish" "set rand_result 0; set rand_seed_lo 1; set rand_seed_hi 0; wait 1; archivecvar rand_result; archivecvar rand_seed_lo; archivecvar rand_seed_hi; alias rand_seed_establish""

alias rand_lo "eval & + * $rand_seed_lo 20077 12345 65535 rand_seed_lo"
alias rand_hi "eval & / % + + % * + * $rand_seed_hi 65536 $rand_seed_lo 413293 ^ 2 32 12345 % * + * $rand_seed_hi 65536 $rand_seed_lo 1103101952 ^ 2 32 ^ 2 32 65536 65535 rand_seed_hi"

alias rand "rand_hi;rand_lo;eval * %1 / % + * $rand_seed_hi 65536 $rand_seed_lo ^ 2 31 ^ 2 31 rand_result;eval & $rand_result $rand_result rand_result"

The first alias, rand_seed_establish, sets up the necessary variables: two seeds and a result CVAR. This first command need only be used once; perhaps it's best to use it via an exec so you don't have to manually copy the entire thing into the console in-game.

The next two aliases need to be defined by you, but you won't have to directly call them. They generate the two seeds.

The final CCMD is the one you will use. Included in this alias is the execution of both of the seed generators. This last alias, rand, requires one parameter, and integer. Then, the command will generate a random number between 0 and your parameter (including 0, but not including your parameter) and will store said number in the CVAR rand_result. This RNG works to very high numbers.

If you want to challenge yourself, deciphering these aliases to figure out how the RNG works will be fun. As you can see, it involves bitwise operation.

Credit goes to Qent for this RNG, but I can explain it to whoever needs me to.


Ah, yes; the most common use of the alias command. Aliases allow for much easier execution of SR50 then would normally be possible. However, before I get into that, first let me briefly explain what SR50 is.

In the Zandronum engine, movement speeds are calculated in such a way that one's actual movement speed is faster if one is both moving forward or backward (+forward/+back) AND left or right (+moveright/+moveleft). Using simple trigonometry with the vectors from both movement directions into the resultant vector, it is found that doing this achieves a speed that is 128% faster than simple running forward. This is called StrafeRun40, or SR40 for short, because the movement speed of the nonforward vector is 40. Executing SR40 will move the player in a direction that is 38.7 degrees off from straight in front. In other words, if you were looking down a long hallway and wanted to SR40 down it, you would turn exactly 38.7 degrees to the right/left then SR40 to the left/right.

However, there is another way to move to the right and left without the +moveright/+moveleft commands. This is achieved with another action command called +strafe, and the keyboard turning commands, +left an +right. The latter two commands (+left and +right) turn the player in the associated direction while keeping the player stationary. Players who player without a mouse or trackpad will often be using these commands to turn. The speed at which these commands turn the player is controlled by a CVAR called turnspeeds, which has 4 parameters, all integers, that determine the turning speed (when turning with the keyboard) in various situations: turning while walking, turning while running, initially turning while walking, initially turning while running (respectively). Setting turnspeeds with one parameter will automatically fill in the rest of the parameters, as they are all in proportion to one another. The +strafe command, when held down, causes the the +left/+right commands to move the player left and right instead.

This leads us to SR50, or straferunning with a strafe component speed of 50 rather than 40. SR50 is achieved when the following conditions are present:

turnspeeds 65536

That's 5 conditions to achieve a speed that is 141% faster than running straight forward and that moves at a 45 degree angle to forward (yes, for those trig-savvy readers, that does mean that forward running speed is 50). SR50 is the fastest ground moving speed attainable normally. One catch, however: you cannot turn while SR50ing!

Binding SR50 will differ based upon whether or not you use a mouse to play the game.

Mouse Users:

You have the advantage, because using the mouse to turn does not use the turnspeeds CVAR, meaning you don't have to worry about it being at its default value of 640 when not SR50ing.

The classic way of SR50ing with a mouse is to use keys to activate +forward, +moveright, and +strafe (forward and right just for example), then to move the mouse in the direction you wish to SR50 to add the turning aspect. This does work, however it has two disadvantages. One, it severely limits your ability to SR50 because of the physical limitation of how far you can move your mouse. Secondly, and more importantly, this way is actually slower on average, because mouse turning speed is not as fast as +left/+right turning at turnspeeds 65536.

I've found the most optimal way to execute SR50 with a mouse to be the following:

First, enter this into your autoexec.cfg:

wait 1

Then, you'll need these aliases:

alias +left2 "+left; +moveleft"
alias -sr "turnspeeds 0; -strafe"
alias +sr "turnspeeds 65536; +strafe"
alias +right2 "+right; +moveright"
alias -right2 "-right; -moveright"
alias -left2 "-left; -moveleft"

Bind +left2 and +right2 to your normal +moveleft and +moveright keys (as in, A and D for most). Then, you'll bind +sr to a key you have easy access to.

The reason why you need the entry into your autoexec.cfg is because the game automatically sets your turnspeeds to 640 every time it loads up, and the +right2 and +left2 commands include the turning commands. With turnspeeds at 0, however, +right2/+left2 won't cause you to turn. However, when +sr is held down, the turnspeeds jump to 65536 and +strafe is activated, so your strafing keys will cause you to SR50. Simply releasing +sr will activate -sr and return your turnspeeds to 0.

You can also do it a different way, by binding two new keys to do the entire thing for you (including the forward, if you wish):

alias +sr50right "+strafe; +right; +moveright; +forward; turnspeeds 65536"
alias +sr50left "+strafe; +left; +moveleft; +forward; turnspeeds 65536"
alias -sr50right "-strafe; -right; -moveright; -forward; turnspeeds 0"
alias -sr50left "-strafe; -left; -moveleft; -forward; turnspeeds 0"

Non-mouse Users (though Mouse Users can use these too!):

Have no fear! You can still SR50!

Technically, those who do not use a mouse can SR50 completely manually, because you have two hands with which you can press keys. In other words, you could simultaneously hold down 5 keys that do:

turnspeeds 65536

Doing it this way can vary, depending upon how you normally move sideways (ie, via +moveright/+moveleft or +strafe), but the bindings shouldn't be hard as you need not create any aliases except perhaps one +/- command to switch your turnspeeds.

However, just in case of your hands is too tied up to activate all the necessary keys, here are some options.

alias +sr50right "+strafe; +right; +moveright; +forward; turnspeeds 65536"
alias +sr50left "+strafe; +left; +moveleft; +forward; turnspeeds 65536"
alias -sr50right "-strafe; -right; -moveright; -forward; turnspeeds 640"
alias -sr50left "-strafe; -left; -moveleft; -forward; turnspeeds 640"

All-purpose keys. Simply bind two new keys to both of these commands, and they will do the entire SR50. Personally I don't prefer this as I dislike moving mmy hand from being centered on the main movement keys, but it's up to you.

Alternatively, here is an extremely complicated but rather fun way to do it without messing up turnspeeds, using bitwise operations:

First, you must put this line into your autoexec.cfg:

set keydown_lrsr 0

Then, you must create a new .cfg; we'll call it strafe.cfg:

// strafe.cfg
// Bitfield keydown_lrsr (left/right straferun): SR50 GORIGHT GOLEFT
// 000 : No keys pressed
// 001 : SR40 left
// 010 : SR40 right
// 011 : SR40 both?
// 100 : SR50 on, movement keys unpressed
// 101 : SR50 left
// 110 : SR50 right
// 111 : SR50 both?

test & $keydown_lrsr 1 +moveleft "-moveleft;-left"
test & $keydown_lrsr 2 +moveright "-moveright;-right"
test & $keydown_lrsr 4 +strafe -strafe
test && & $keydown_lrsr 1 & $keydown_lrsr 4 +left -left
test && & $keydown_lrsr 2 & $keydown_lrsr 4 +right -right

Finally, you'll need these aliases:

alias +sr "eval | $keydown_lrsr 4 keydown_lrsr;exec strafe.cfg"
alias -sr "eval & $keydown_lrsr -5 keydown_lrsr;exec strafe.cfg"
alias +left2 "eval | $keydown_lrsr 1 keydown_lrsr;exec strafe.cfg"
alias -left2 "eval & $keydown_lrsr -2 keydown_lrsr;exec strafe.cfg"
alias +right2 "eval | $keydown_lrsr 2 keydown_lrsr;exec strafe.cfg"
alias -right2 "eval & $keydown_lrsr -3 keydown_lrsr;exec strafe.cfg"

This system of executions uses bitwise operations to allow test series of evals and tests to result in a greater number of potential outcomes than would otherwise be possible, allowing for the same optimal binds that mouse users can use.

Credit goes to Qent for the above, though I can explain it if need be.

But wait, there's more!

That's right, I've been leading you on the whole time. While that last one sure is cool, this is really the best:

alias -sr50left "test = 1 1 "-moveleft; -left""
alias -sr50 "set sr50_on 0; turnspeeds 640; -strafe; test = 1 1 "-left; -right""
alias +sr50left "test = $sr50_on 1 "+left; +moveleft" "+moveleft""
alias -sr50right "test = 1 1 "-moveright; -right""
alias +sr50 "set sr50_on 1; turnspeeds 65536; +strafe"
alias +sr50right "test = $sr50_on 1 "+right; +moveright" "+moveright""

Same strategy here, just way simpler! The test commands on the - commands are there to bypass an engine restriction that would not execute the - movement commands.

Credit goes to Circunei Z for the above SR50 setup method.

And that's SR50! Who knew it was so extensive?

(click to show/hide)The KEYCONF lump is a very easy way to store, edit, and transfer aliases. For those who don't know, a lump is basically just one part of a WAD file, which are the files used to load content into the game.

However, KEYCONF is one of the few lumps that you can load as a client when joining server. Basically, you just create a WAD in SlumpEd or Slade that consists of just a text lump named KEYCONF.

The KEYCONF lump supports a number of different commands that all have to do with client configurations and settings. It supports these (only relevant item listed):



defaultbind [key] [function] - A bind command that executes only if the [key] parameter does not already have a bind and if [function] is not already bound to something else)

addkeysection [menu heading] [ini section] - Adds a new heading of name [menu heading] to the controls menu, and also adds a new section [ini section] to the .ini file for these new controls.

addmenukey [description/name] [command] - Adds a new control to the control menu to be assigned. The new control is of name [description/name] and executes [command]. New menu keys are added to the most recently added keysection defined by

The KEYCONF lump uses the syntax used by the console for each of the above commands. Place your KEYCONF lump wad in yours skins folder so it will automatically load whenever you start the game, even online. The client usage of KEYCONF is almost identical to autoexec.cfg, but you can easily have multiple KEYCONF wads without changing .ini settings and using the KEYCONF makes syntax easier to see (make sure you define the text language as KEYCONF in Slade/SlumpEd).
IX. Tips and FAQ[/size]

This will be added to over time!

A. More Helpful Tips!

(click to show/hide)* If you put the logfile command along with a dedicated folder location in your autoexec.cfg and define logfile as a command to be executed atexit, you will automatically log every game! This is great for archiving purposes, for instance.

* The cmdlist and cvarlist commands print the name of every defined CCMD and CVAR, respectively, into the console. Be warned, these lists may exceed the line history of the console so you'll need to log the console to see them all.

* If you begin typing into the console and press TAB, the console will print a list of every CVAR or CCMD that begins with what you had. For example, if you type sv_ into the console then press TAB, the console will print every sv_ variable name.

* Pressing the UP ARROW while in the console will begin scrolling through previously entered lines, starting with the most recent. From there, you can use UP ARROW and DOWN ARROW to scroll through them.

(click to show/hide)Q: Help! I made a bunch of binds/aliases when I last played the game but now they're not here anymore! What happened?

A: In order for changes to be saved to your .ini file, you have to exit the game normally; that is, entering the menu, hitting exit, then pressing Y. Closing the game window or crashing out will not save your settings. You can also exit the game via the CCMD 'exit' and your settings will be saved. Also, to be safe, don't have your .ini file open when you close the game.

Q: Why can't I bind the ; key?

A: The console interprets the ; key in a special way, as it is used to separate commands in a string of commands. In order to bind to the ; key, use quotes around ;. Like this:

bind ";" +jump

Q: How do I bind keys on the number pad?

A: Keys on the number pad, with the exception of ENTER and NUMLOCK, are all preceded by kp in their console names. So, kp7, kp+, kp., kp0, etc.

Q: How do I bind to the key next to the righthand CTRL?

A: That key, the one that has the little screen symbol on it, is called APPS.

Q: How do I bind to all of the cool buttons on my cool mouse?

A: If you can press the scroll wheel down, the game interprets that as MOUSE3. Forward and back buttons are often interpreted as MOUSE4 and MOUSE5, though not necessarily respectively. If your scroll wheel can tilt to the left and right, you'll have to edit your mouse's settings to have your computer (or just your game(s)) interpret these tilts as two different keys on the keyboard, then bind to those keys. If your mouse has any more keys, they'll either continue with MOUSE[x], or your mouse's settings will help you with what you need.

Q: How do I unbind keys?

A: unbind [key]
undoublebind [key]

Or you can just bind over old binds!

Q: Help! I got kicked from a server when I was changing my name/skin/class! Why?

A: There are a few settings/CVARs, including skin, name, and playerclass, that are grouped into a collection of CVARs called 'user info.' If you change more than one of these at the some time or within a few tics of each other, the game will kick you for 'user info change flood.' This is to prevent spamming name changes, etc.

Q: Help! When I try to move left or right, I start turning! Why is this, and how do I fix it?

A: It's likely you tried one of the SR50 binds and didn't add the suggested lines to autoexec.cfg. To fix this, simply press and release +sr. Your left/right movement keys include turning commands, so your turnspeeds must be 0 so you don't turn.

Please post with comments, questions, suggestions, corrections, etc.! I'm sure there is plenty I've missed!

I...honestly wasn't aware of the existence of rebinding...interesting.
I will probably need to bookmark this page because it could be useful for hosting servers and stuff.

Laggy Blazko:
The only thing I couldn't found there is something related to chatmacros (well, most people use binds to say predefined things anyway (I use aliases more, instead =P )), but nice guide.
+1 bookmark.

The Killer Nacho:
If this doesn't deserve a sticky, I don't know what does. There are some commands missing that can be found here: (Sorry in advance if this link is far too obvious and you only included important client commands.)

I would write it out here, but if this link were placed near the top of the guide, new users might be heavily inclined to click it and read the stuff on it (which includes both client and server commands, the latter of which may be useful for new hosts in our community). Heck, I've been playing MM8BDM for  several months and before now I had no idea rebind existed like Lego. Overall, props for such a comprehensive guide. (So comprehensive, in fact, you just completely made the SR50 binding guide by Tesseractal obsolete :lol: )

One thing to keep in mind: $HEALTH and the likes are not Integers, which means you can't use number operations like + or > on them. I feel like this should be more explicitly added to the part where they are mentioned in order to avoid confusion or at least made as a list and not be on the same level as the CVARs.


[0] Message Index

[#] Next page

Go to full version