View on GitHub

ezEngine Documentation

The documentation for ezEngine


The in-game console is a utility for inspecting the log, modifying CVars and calling console functions.


Key bindings

The default key binding for the console is:

Modify CVars

You can modify CVars by typing:

CVarName = value

See the CVars chapter for details.

Binding Keys

To bind commands to certain keys you can call:

bind f g_showFPS=

This would bind the command ‘g_showFPS=’ (which toggles the display of the FPS counter) to the f-key. You can only bind commands to printable characters (a-z, 0-9) and the casing matters. So you can also bind another command to SHIFT+f by using bind F ....

To unbind a key call:

unbind f

You can filter the output of the console (the log messages) to only strings that contain some string by typing a * at the beginning:

*some text

Now the output window will only show strings that contain ‘some text’.

Console Functions

Console functions are an easy way to expose C++ utility functions through the console. The class ezConsoleFunction is used to wrap any function (static or method function) in a delegate and enable the console to call it. Of course, since the user can only input certain types of variables in the console, the argument types that you can use are very limited: strings, numbers (int / float) and boolean.

This code snippet shows how to declare a console function in a class, for example inside a custom game state.

void ConFunc_Print(ezString sText);
ezConsoleFunction<void(ezString)> m_ConFunc_Print;

In the implementation the binding has to be completed. You need to provide a name under which to expose the function, a description (this should include the parameter list) and the actual function to forward the call to. For member functions this has to be an ezDelegate to also bind to the class instance (this).

  : m_ConFunc_Print("Print", "(string arg1): Prints 'arg1' to the log", ezMakeDelegate(&SampleGameState::ConFunc_Print, this))

void SampleGameState::ConFunc_Print(ezString sText)
  ezLog::Info("Text: '{}'", sText);

When you now open the console (F1) in-game and press TAB, the ‘Print’ function will be among the listed functions. You can then execute it:

Print("Hello Console")

If you need to call a certain function repeatedly, you can bind the call to a key or use F2 and F3 to repeat it, as long as it is the last or second-to-last command in your history.


You can also register custom console functions through the TypeScript API.

See Also