-
Notifications
You must be signed in to change notification settings - Fork 12
Console Commands
Valk edited this page Sep 19, 2024
·
7 revisions
Adding the ConsoleCommand attribute to any function will register it as a new console command.
Note
The in-game console can be brought up with F12
[ConsoleCommand("help")]
void Help()
{
IEnumerable<string> cmds = Game.Console.Commands.Select(x => x.Name);
Game.Log(cmds.Print());
}Console commands can have aliases, this command has an alias named "exit"
[ConsoleCommand("quit", "exit")]
void Quit()
{
GetTree().Root.GetNode<Global>("/root/Global").Quit();
}Most method parameters are supported, allowing for more dynamic interactions
[ConsoleCommand("debug")]
void Debug(int x, string y)
{
Game.Log($"Debug {x}, {y}");
}