paulloz / godot-ink

Ink integration for Godot Engine.
MIT License
560 stars 41 forks source link

Calling an ink function bound using BindExternalFunction to a gdscript lambda function fails. #94

Open darthnotarius opened 3 weeks ago

darthnotarius commented 3 weeks ago

Describe the bug

As title.

To Reproduce

test.ink

-> example

EXTERNAL test1()
EXTERNAL test2()

=== function test1() ===
~ return

=== function test2() ===
~ return

=== example ===
~ test1()
~ test2()

-> END

test.gd

extends Node

func _ready() -> void:
    var story: InkStory = load('res://test.ink')
    story.BindExternalFunction("test1", test1, false)
    story.BindExternalFunction("test2", func(): print('test2 ok'), false)
    story.Continue()

func test1() -> void:
    print('test1 ok')

output

test1 ok

debugger

E 0:00:01:0016   test.gd:8 @ _ready(): Attempt to call callable 'null::null' on a null instance.
  <C# Source>    /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs:159 @ void Godot.NativeInterop.ExceptionUtils.DebugCheckCallError(Godot.NativeInterop.godot_callable&, Godot.NativeInterop.godot_variant**, int, Godot.NativeInterop.godot_variant_call_error)
  <Stack Trace>  test.gd:8 @ _ready()

Environment

paulloz commented 2 weeks ago

Hello.

GDScript lambdas currently aren't supported by C#/GDScript interop. This would have to be implemented upstream in the engine to work.