Using the Command Console

From C4 Engine Wiki

Jump to: navigation, search

The Command Console window can be opened at any time by pressing the tilde/grave key. (On some non-English keyboards, the key directly below the Escape key should be used.) The window displays a command line and an output buffer as shown in the image to the right. If the C4 Engine was built using the debug settings, the window displays "(Debug)" to the right of the build number.

The console stores a small command history that can be accessed with the up and down arrow keys.

Contents


Core Engine Commands

The following table describes some of the commands that are built into the engine. New commands can be added by an application or plugin module (see below).

Command

Description

address

Displays the IP address of the local machine. Must be in a network game.

bind key "command"

Binds the key whose name is key to the command specified by command. Whenever the bound key is pressed in gameplay mode, the specified command is executed.

body

Toggles the display of bounding boxes for active rigid bodies.

cmd

Displays a list of available console commands.

coll

Toggles the display of collision edges.

disconnect

Disconnects from a multiplayer game.

dump

Writes a list of all currently allocated memory blocks to the file "Memory.txt". Leak detection must be turned on.

exec path

Executes the file Data/*/path.cfg.

ext

(Advanced) Opens the Graphics Extensions dialog, to enable or disable various OpenGL extensions.

gentex

Opens the Texture Generation tool, which renders textures for light projections, shadow maps, environment maps, and ambient spaces. (Can only be invoked while a game world is running.)

gl

Displays various OpenGL diagnostics in the console.

heap

(Advanced) Displays memory heap totals in the console.

load name

Loads the world name.wld for gameplay.

lrgn

(Advanced) Toggles the display of light regions.

mem

Opens the Mem window, which displays the amount of allocated memory.

net

Opens the Network window, which displays various network statistics. (The Network window can also be opened by choosing Tools > Network Window.)

norm

Toggles the display of normal vectors.

quit

Quits C4.

rate

Opens the Rate window, which displays the frame rate in frames per second. (The Rate window can also be opened by choosing Tools > Frame Rate Window.)

resolve hostname

Resolves a host name to an IP address. Must be in a network game.

restore name

Restore the previously saved game Save/name.sav.

save name

Save the current game as Save/name.sav.

say "message"

Sends a chat message to all players in the current multiplayer game.

sbnd

(Advanced) Toggles the display of shadow bounding volumes.

shad

(Advanced) Toggles the display of shadow volume extrusions.

shot name

Takes a screenshot and saves it as name.tga. If a # character appears in the name, then the name from that point on is replaced with a screenshot count that starts at 1 and gets incremented each time it is used in a screenshot name.

stat

Opens the Stats window, which displays various engine statistics. (The Stats window can also be accessed by choosing Tools > Stats Window.)

tang

Toggles the display of tangent vectors.

unbind key

Unbinds the key whose name is key.

undef name

Undefines the variable name, if the variable is not permanent.

unload

Unloads the current gameplay world.

var

Displays a list of currently defined system variables.

wire

Toggles the display of wireframes.


Tool Commands

The following commands are defined by the standard tools that ship with the C4 Engine. Each of these commands has an equivalent item in the Tools menu. If the name parameter is omitted from any of these commands, then a file picker dialog will appear to let you select a file.

Command

Description

gfont

Opens the Font Generator tool. (This tool can also be opened by choosing Tools > Generate Font.)

istring name

Imports the string table file name.txt. (String tables can also be imported by choosing Tools > Import String Table.)

itexture name

Imports the texture file name.tga. (Textures can also be imported by choosing Tools > Import Texture.)

model name

Opens the model file name.mdl in the Model Viewer tool. (Models can also be opened by choosing Tools > Open Model.)

movie name

Opens the movie file name.mov in the Movie Player tool. (Movies can also be opened by choosing Tools > Open Movie.)

pack name

Creates a pack file, where name is the name of a top-level subfolder in the Data directory.

sound name

Opens the sounds file name.wav in the Sound Player tool. (Sounds can also be opened by choosing Tools > Open Sound.)

texture name

Opens the texture file name.tex in the Texture Viewer tool. (Textures can also be opened by choosing Tools > Open Texture.)

world name

Opens the world file name.wld in the World Editor tool. (Worlds can also be opened by choosing Tools > Open World.)


Defining New Commands

Application modules and tool modules can add their own commands to the engine by creating new instances of the Command class. The constructor for the Command class takes a command string and a pointer to an observer object that is invoked when the command is executed. For example, to define a command called explode that causes the MyClass::ExplodeFunction() function to be called, you would construct a new Command instance as follows.

CommandObserver<MyClass> explodeObserver(this, &MyClass::ExplodeFunction);
Command *explodeCommand = new Command("explode", &explodeObserver);

Once the command has been constructed, it needs to be added to the engine's command list before it will be recognized. This is done by calling the Engine::AddCommand() function. Continuing the explode example, you would make the following call to add the explode command to the engine.

TheEngine->AddCommand(explodeCommand);

Destroying the Command instance automatically removes the command from the engine.

The observer event handling function assigned to a new command must have the following prototype.

void ExplodeFunction(Command *command, const char *text);

When a command is entered into the console (or executed from a file), the observer event handler is invoked, and the text passed in through the text parameter provides the rest of the command line. For instance, the command explode 1 boom would cause the ExplodeFunction() function to be called with a pointer to the string "1 boom".


See Also

Personal tools