Console

From SRB2 Wiki
Jump to navigation Jump to 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 latest-log.txt file; as of v2.2, a new log file is created for each session of the game being played, named after the date and time that the session was initiated. In previous versions, the log file would be overwritten on each session.

The console is opened by pressing the Console key defined in the controls, which by default is the backquote (`) or tilde (~) key on US 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.

Chat window

See also: Console/Variables > Chat

In multiplayer gametypes, the console is supplemented by a chat window which is displayed in the lower left part of the screen. By default, the chat window is closed. When a chat message is received, a "beep" sound is played (this can be disabled with the chatnotifications console variable) and the message is displayed in the area of the chat window for a few seconds before disappearing (the time that it stays on screen can be configured with the chattime console variable). The full chat window, containing all previously received messages, can be opened by pressing the Talk or Team Talk key and closed with the Escape key. Inside the chat window, the user can type in chat messages and send them by pressing Enter. By default, chat messages are sent to all other players. In team-based gametypes such as Team Match and CTF, if the chat window was opened with the Team Talk key, the message will be sent only to players on the same team. To send a private message only to a particular player, the message must be started with /pmx, where x is the player number. If /pm is typed into the chat window, it will automatically list available players and their player numbers.

In addition to displaying chat messages, the chat window also logs other important player actions, such as players joining or leaving the game; these are colored in yellow. 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 player's name; these messages are also colored yellow.

The chat system is spam-protected, i.e., if a player sends too many messages in rapid succession, these messages will not be displayed. The spam protection can be turned off with the chatspamprotection console variable. The chat window can be disabled by setting the chatmode console variable to Console; in this case, chat messages will be displayed in the console instead. If the chat mode is set to Window (Hidden), the chat window will be used, but received chat messages will not pop up on the screen and will only be displayed if the user explicitly opens the chat window.

As an alternative to the chat window, chat messages can also be sent via the console with the commands say (for messages to all players), sayteam (for messages to the player's team) and sayto (for private messages to a particular player).

Console messages

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

Chat messages

Chat messages appear in the chat window by default, but if the chat window is disabled, they appear in the console instead. In either case, they are saved to the console log.

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 file detected on load
Error High-importance alert; e.g., maximum files reached, 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 or PK3 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