Simple in-game console for Godot 4.x.
git clone
this repository to the addons
folder or download the latest releases.Godot Console
in Plugins.ConsoleContainer
node to the scene.# player.gd
func teleport(x: float, y: float) -> void:
self.position = Vector2(x, y)
func _ready() -> void:
Console.create_command("tp", self.teleport, "Teleport the player.")
With static typing, Console will try to cast arguments to a supported type.
# Arguments are float.
func teleport(x: float, y: float) -> void:
self.position = Vector2(x, y)
With dynamic typing, Console will NOT cast arguments to type, and arguments will be a String.
# Arguments are Strings.
func teleport(x, y):
# Convert arguments to float.
self.position = Vector2(x.to_float(), y.to_float())
func add_money(value: int) -> String:
self.money += value
# Prints: Player money:42
return "Player money:%d" % money
You can add 'addons/godot-console/scripts/ConsoleMono.cs' to Autoloads after 'Console'.
public partial class Test : Node
{
private void Foo(string a, string b)
{
ConsoleMono.Print(a + " " + b);
}
public override void _Ready()
{
ConsoleMono.CreateCommand("foo", Foo); // You can pass method directly as delegate.
ConsoleMono.CreateCommand("foo2", this, MethodName.Foo); // Or you can pass target object and method name.
}
}
Copyright (c) 2020-2024 Mansur Isaev and contributors
Unless otherwise specified, files in this repository are licensed under the MIT license. See LICENSE.md for more information.