navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 2 (modified by landauf, 12 years ago) (diff)




A ConsoleCommand is a function which can be called by the Shell?. ConsoleCommand inherits from Executor and adds some additional features used to bind commands to keys and to allow easy use in the Shell (like argument completion).

At the moment, a ConsoleCommand must call a static function. The command is of static nature too and exists for the whole time. But this will change in the future.

A ConsoleCommand can also be called directly from the code by using CommandExecutor. If you want to execute the same command over and over, see CommandEvaluation for more performance.



Creating a ConsoleCommand is usually really easy. Just write the following lines:

*.cc file:

#include "core/ConsoleCommand.h"

SetConsoleCommand(ClassName, functionname, true);

Note: The last argument (true) means: create a shortcut for this command.

*.h file:

class ClassName
        static returntype functionname(param1, param2, ...);


Now you can call the function by typing the functionname into the Shell?:

> functionname arg1 arg2 ...
> ClassName functionname arg1 arg2 ...

Note: The first variant works only if you enable the shortcut (true in SetConsoleCommand).

It's also possible to call the command directly from the code by using CommandExecutor:

CommandExecutor::execute("functionname arg1 arg2 ...");
CommandExecutor::execute("ClassName functionname arg1 arg2 ...");


There are several attributes you can set, some of them are inherited from Executor, some are new.


  • description(description): Sets the description of the Executor (what the function does)
  • descriptionParam(param number (0-4), description): Sets the description of an argument (what the argument does)
  • descriptionReturnvalue(description): Sets the description of the return value (what the return value does)
  • defaultValues(value1, ): Sets default values
  • defaultValue(param number (0-4), value): Sets the default value for a given parameter


  • keybindMode(mode):
  • axisParamIndex(index):
  • isAxisRelative(bool):

Chained attributes

You can specify all attributes from above in one single chained call, for example:

SetConsoleCommand(ClassName, functionname, true).description("Does something nice").defaultVal
    ues(10, "test", true, 1.234).argumentCompleter(0, autocompletion::completerfunction()).isA

Note: The attributes can be specified in any order.

Access Levels

-to come-

Argument Completion

-to come-

Attachments (1)

Download all attachments as: .zip