
Game Console 0.5.0 Tools 4.3 Community
Submitted by user Xanatos; MIT; 2025-05-05
Addon to add a console to your game, this will allow you to run commands after opening the console.
To add a command simply use
Console.register_custom_command("reload", _reload, [], "Reload current scene")
where reload is a function without parameters.
If you want to parse parameter use
Console.register_custom_command("count_up", _count_up, ["(int) amount to count up"], "Increase the counter", "Command will increase a local counter", ["count_up 1", "count_up 3"])
This adds a command with a single argument, a short and long description and some examples.
You can also make arguments optional, to do so create them like that:
var count_down_command = Command.new("count_down",
_count_down,
[CommandArgument.new(CommandArgument.Type.INT, "amount", "The amount to count down from the current counter", "1")],
"Decrease the internal counter",
"Command will decrease a local counter",
["count_down", "count_down 2", "count_down 5"])
Console.register_command(count_down_command)
or use the "Console.register_custom_strong_command()" method, which uses the "CommandArgument" instead of the packedstring array for arguments.
Always make sure that your optional parameters are at the end of your parameter list, otherwise the command registration will fail.
To unregister it run, this should be done if a node does leave the scene tree.
Console.remove_command("reload")
Other interessting methods
## Change the console settings
## There are more options
Console.update_console_settings(func(settings: ConsoleSettings):
## Set key to toggle console
settings.open_console_key = KEY_F12
## Pause game tree if console does open up
settings.pause_game_if_console_opened = true
)
## Hide console
Console.hide_console()
## Show console
Console.show_console()
## Disable console completely, can be used to remove it on release builds
Console.disable()
## Enable a disabled console
Console.enable()
# BREAKING_CHANGES:
## Version 0.4.0 -> 0.5.0
This version will add some breaking changes, if you create a
command instance you cannot use the packedstring array anymore. Instead
create a new "CommandArgument" providing the type as first parameter,
the name as the second and if needed a description of the parameter as
last. See the example project or readme for more details
View files Download Submit an issue Recent Edits