Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Command Console

Dylan Dumesnil edited this page Jun 30, 2020 · 2 revisions

In game, the command console can be opened with the ~ key. Command history can be navigated using the Up and Down arrow keys. To auto complete the command, hit Tab.

In your code, you can add more commands by adding the [MDCommand()] attribute to any methods you wish to have as commands. Then from that same class call this.RegisterCommandAttributes(); to have those commands registered or see the Automatic Registration section to have it done automatically. For classes extending Node, they aren't registered automatically as commands are a debug feature, so a good place to call it would be in _Ready(), Node classes have an extension helper for this, so you can just call this.RegisterCommandAttributes();.

Only a single instance of a class can be registered for commands, this is because commands are invoked via their method name, which are the same for all instances of a class.

To call a command on the server from the client, prefix the command with ServerCommand, for example ServerCommand Disconnect.

You can override IsConsoleAvailable() on your GameInstance implementation to change when the console is available, by default it's only available in DEBUG builds.