godot-console
godot-console copied to clipboard
Optional arguments dont work in C#
I'm using:
- Godot 3.4.4
- godot-console 3.5.1
Given:
public override void _Ready()
{
// ...
wrapper.AddCommand("start_host", this, nameof(BeginServer))
.SetDescription("beings a dedicated host on %port% with %maxPlayers%. \"")
.AddArgument("port", Variant.Type.Int)
.AddArgument("maxPlayers", Variant.Type.Int)
.Register();
}
public Error BeginServer(int port = 25000, int maxPlayers = 2)
{
// ...
}
the command is successfully registered. If i run the command with arguments provided:
start_host 25000 2
then the command successfully runs. However, if i run the command without some or any arguments provided:
start_host
then I get a runtime error:
E 0:00:04.577 callv: Error calling method from 'callv': 'Spatial(Game.cs)::BeginClient': Method not found..
<C++ Error> Method failed. Returning: Variant()
<C++ Source> core/object.cpp:829 @ callv()
<Stack Trace> Callback.gd:58 @ call()
Command.gd:72 @ execute()
ConsoleLine.gd:112 @ execute()
Thanks for reporting.
Sadly I know little about C# and it's state in godot. I would guess that callv
implementation that bridges godot to C# expects a method with a number of arguments equal to number of arguments passed to callv :/
If you could raise this issue to godot engine devs that would be helpful. If not I'll try to get to it later.