grow-graphics / gd

Go + Godot 4.3
https://learn.grow.graphics/
MIT License
244 stars 11 forks source link

Return Parameters #11

Closed creichlin closed 8 months ago

creichlin commented 8 months ago

When i create and register the following class:

type Test struct {
    gd.Class[Test, gd.Node]
}

func (r *Test) Test(gd.Context) {
    fmt.Println("Hello Test")
}

func (r *Test) Test2(context gd.Context, seed gd.Int) gd.String {
    fmt.Println("Hello Test 2", seed)
    return context.String("Test 2 Result")
}

I can instantiate the class and call the Test() method. The Test2 method is not found though.

When i checked the source i saw that methods with a return parameter are implemented but disabled and when i enabled them the method could be called from godot but it always returned an empty string.

Is that part still work in progress or is there another preferred way to return data back to godot?

Splizard commented 8 months ago

@creichlin thanks for reporting, I've enabled return values and fixed the issue for returning strings (and other Godot reference types). In the example project, GOARCH is now printed to the console by Godot which retrieves this value as a gd.String by calling a Go method via GDScript.

creichlin commented 8 months ago

Thanks for fixing it so fast! It works as expected now.