Using the Command Console
From C4 Engine Wiki
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 |
|
|
Displays the IP address of the local machine. Must be in a network game. |
|
|
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. |
|
|
Toggles the display of bounding boxes for active rigid bodies. |
|
|
Displays a list of available console commands. |
|
|
Toggles the display of collision edges. |
|
|
Disconnects from a multiplayer game. |
|
|
Writes a list of all currently allocated memory blocks to the file "Memory.txt". Leak detection must be turned on. |
|
|
Executes the file |
|
|
(Advanced) Opens the Graphics Extensions dialog, to enable or disable various OpenGL extensions. |
|
|
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.) |
|
|
Displays various OpenGL diagnostics in the console. |
|
|
(Advanced) Displays memory heap totals in the console. |
|
|
Loads the world |
|
|
(Advanced) Toggles the display of light regions. |
|
|
Opens the Mem window, which displays the amount of allocated memory. |
|
|
Opens the Network window, which displays various network statistics. (The Network window can also be opened by choosing Tools > Network Window.) |
|
|
Toggles the display of normal vectors. |
|
|
Quits C4. |
|
|
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.) |
|
|
Resolves a host name to an IP address. Must be in a network game. |
|
|
Restore the previously saved game |
|
|
Save the current game as |
|
|
Sends a chat message to all players in the current multiplayer game. |
|
|
(Advanced) Toggles the display of shadow bounding volumes. |
|
|
(Advanced) Toggles the display of shadow volume extrusions. |
|
|
Takes a screenshot and saves it as name |
|
|
Opens the Stats window, which displays various engine statistics. (The Stats window can also be accessed by choosing Tools > Stats Window.) |
|
|
Toggles the display of tangent vectors. |
|
|
Unbinds the key whose name is key. |
|
|
Undefines the variable name, if the variable is not permanent. |
|
|
Unloads the current gameplay world. |
|
|
Displays a list of currently defined system variables. |
|
|
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 |
|
|
Opens the Font Generator tool. (This tool can also be opened by choosing Tools > Generate Font.) |
|
|
Imports the string table file |
|
|
Imports the texture file |
|
|
Opens the model file |
|
|
Opens the movie file |
|
|
Creates a pack file, where |
|
|
Opens the sounds file |
|
|
Opens the texture file |
|
|
Opens the world file |
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".

