Console

From SRB2 Wiki
Jump to: navigation, search
The console showing a list of commands and variables after using the help command.

In SRB2, the console is an internal command prompt that allows the user to control many of the game's options and to perform certain actions. Sometimes the same effects can be achieved using the menus, but many features can only be accessed via the console. The console is also used to display messages to the user and log important game events. A log of the console input and output during the current SRB2 session is saved to the log.txt file; it is overwritten after starting a new session.

The console is opened by pressing the Console key defined in the controls, which by default is ~ (tilde) on US keyboards and ` (backquote) on UK keyboards. Pressing the key again closes the console. The console will not be accessible to the user when in Record Attack/NiGHTS Mode, or when a Metal Sonic replay is being recorded.

Controls

The controls for handling the console when active are listed below:

General
Escape Closes the console, if open. Note that in most situations, this will simply bring up the main menu or the respective pause menu if in-game, immediately closing the console.
Left Arrow/
Right Arrow
Moves the input cursor left/right. If Shift is held down at the same time, the cursor can be used to select text in the input (the selected text is highlighted yellow).
Home Immediately moves the input cursor to the beginning of the input line. If Shift is held down at the same time, this causes all input text before the cursor's old position to be selected (the selected text is highlighted yellow).
End Immediately moves the input cursor to the end of the input line. If Shift is held down at the same time, this causes all input text after the cursor's old position to be selected (the selected text is highlighted yellow).
Enter Executes the text in the input line.
Backspace Deletes the character behind the input cursor. If any text is selected in the input, the selected text is deleted instead.
Delete Deletes the character in front of the input cursor. If any text is selected in the input, the selected text is deleted instead.
Text selection
Ctrl + X Cuts selected text from the input line to the clipboard.
Ctrl + C Copies selected text from the input line to the clipboard.
Ctrl + V Pastes the last cut/copied text to the input line from the clipboard.
Ctrl + A Selects all text in the input line.
Input/output history
Up Arrow/
Down Arrow
Moves back/forward through the console's input history, i.e., the text that the user has typed into the console and executed during the SRB2 session.
Page Up/
Page Down
Scrolls up/down through the console's output history, i.e., the text that has been printed out by the console during the SRB2 session.
Shift + Home Immediately scrolls to the oldest output text in the console.
Shift + End Immediately scrolls to the most recent output text in the console.
Auto-complete
Tab Auto-completes a partially entered console command/variable name, if this has not been done already. Pressing this key again will display the next possible command/variable in the full list of possible options.
Note: This list goes through all possible commands alphabetically first, followed by all possible variables alphabetically.
Shift + Tab Auto-completes a partially entered console command/variable name, if this has not been done already. Pressing this key again will display the previous possible command/variable in the full list of possible options.
Ctrl + Tab Lists all possible console commands/variables that match the partially entered text in the console, separating the commands and variables into their own lists.

Console messages

There are several special types of messages that can appear in the console during an SRB2 session:

Chat messages

These are messages that have been sent by a player through the Talk or Team Talk keys (or the commands say, sayteam and sayto). They display the name of the player who sent them, and are accompanied by a "beep" sound when arriving.

A chat message can be made to appear like a player action by starting it with the placeholder /me, which will automatically be replaced with the user's name. These messages are colored yellow in the chat log and console.

Alerts

Alert messages appear with a colored prefix when printed in the console. There are three types of alert messages in SRB2:

Alert type Description
Notice Low-importance alert; e.g., incorrect input
Warning Medium-importance alert; e.g., minor issue in WAD detected on load
Error High-importance alert; e.g., maximum WAD files reached, WAD file not found

Debug

When development mode is activated, messages containing debug information will be printed to the console. The amount and type of debug messages that are printed depends on which feature flags of development mode are enabled.

Commands and variables

Commands and variables are an important feature of the console – they allow the user to perform actions or change various game settings by simply entering the corresponding commands or variables into the console. Alternatively, these can be executed through console scripts or the command line; see the sections below for more details. Commands and variables differ in the following ways:

  • Commands will perform a specific action instantly after being entered. These are generally one-time actions that have no lasting effects beyond the current SRB2 session, such as chat messages, netgame actions such as kicking/banning people, or game-modifying actions such as cheats or adding WAD files to the game – the exception to this is setcontrol, a special command used to configure the player's controls that is saved in config.cfg. Some commands may accept one or several parameters; others have no parameters and are executed on their own.
  • Variables are game settings that have a value assigned to them. The value of a variable can be changed by entering the variable's name into the console, followed by a single parameter – the value that it should be set to. For example, entering color blue into the console will change the value of the variable color to blue, which causes the player's color to change to blue. The type of the value parameter depends on the variable – it can be a boolean, integer, decimal number, or a string, depending on what is required. Some variables only allow the user to select specific values from a list, or select a value from a predetermined range. A large portion of variables are saved in config.cfg, allowing them to be carried over to the next SRB2 session even after closing the game. Most console variables also have equivalent entries in the game's Options menu.

Command and variable names are not case-sensitive; for the sake of consistency, they are generally written in all-lowercase when mentioned on the SRB2 Wiki.

Special characters

Certain characters are used in the console and console scripts with commands and variables for special purposes.

Semicolon (;)

The semicolon character (;) is used to separate commands or variables from each other, when several of them should be executed on the same line. For example, color purple; skin knuckles will change the player's color to purple, then change the player's skin to Knuckles.

Quotation mark (")

The quotation mark character (") can be used to enclose strings that are passed as parameters to a command or variable. They are only required if the string contains a space or any of the following characters (separated by spaces):

{ } ( ) ' ;

This is useful for instances where a command/variable with parameters is itself passed as a parameter to another command. For example, bind 1 "say hi" will bind say hi to a key – in contrast, bind 1 say hi would not work as say and hi are now treated as two separate parameters.

Console scripts

Main article: Console script

A console script is a text file that contains a sequence of commands and variables. Such a script can be loaded by SRB2, which will automatically execute all the commands and variables contained in it. This is useful for executing long sequences of commands and variables without having to type them manually each time. While it is not required, command/variable names and parameters are usually written in all-lowercase for readability (except for button names like KEY93). They can be separated either by lines or by semicolons.

For example, consider the following script called tunebinds.txt:

bind 1 "tunes 45"
bind 2 "tunes 29"
bind 3 "tunes 93"
bind 4 "tunes 102"

To load and execute a script file, enter exec <script filename> into the console, e.g., exec tunebinds.txt for the above example.

autoexec.cfg

autoexec.cfg is a special script file that will be loaded automatically on startup. It does not exist by default; you have to create it yourself (for example with Notepad) and place it into the SRB2 directory. It can be used to store default settings such as a name, color, and skin for netgames, as well as other things such as binds and aliases.

adedserv.cfg

adedserv.cfg is a special script file that will be loaded automatically when starting a dedicated server. Like autoexec.cfg, it does not exist by default and must be created manually if needed.

Command line

See also: Command line parameters

Console commands and variables can be passed as command line parameters to SRB2's executable. They will then be automatically executed on startup. There are several ways to pass command line parameters to SRB2, for example in the SRB2 Launcher's command line, in the Windows Command Prompt, or in a batch file. For example, a batch file called skinandcolor.bat containing the text srb2win.exe +skin sonic +color blue would start SRB2 and immediately set the player's skin to Sonic and color to blue.

The syntax for commands and variables passed as command line parameters is the same as in the console itself, except prefixed with a plus sign (+), e.g., +map map01 or +skin sonic. However, this will not work for any command/variable parameters starting with a minus sign (-), e.g., -force for the map command – the game will interpret them as regular command line parameters instead of associating them with the command/variable they belong to, and therefore ignore them.

See also