Skip to content

Interop with GDScript

Paul Joannon edited this page Feb 21, 2023 · 2 revisions

For the most part, calling in GodotInk from GDScript is as straightforward as from C#. Still, there are a few gotchas to keep in mind.

Read-only properties

Due to limitations with read-only properties, part of the API can seem unreachable. That's why GodotInk provides fallback methods for all its read-only properties.

Class name Property name Method name Return type
InkStory CanContinue GetCanContinue() bool
CurrentChoices GetCurrentChoices() Godot.Collections.Array<InkChoice>
CurrentTags GetCurrentTags() Godot.Collections.Array<string>
CurrentText GetCurrentText() string
InkChoice Text GetText() string
PathStringOnChoice GetPathStringOnChoice() string
SourcePath GetSourcePath() string
Index GetIndex() int
Tags GetTags() Godot.Collections.Array<string>

Callables

Interoperability between GDScript and C# Callable types is a little limited at the moment. When using Callable with GodotInk, avoid using bound arguments.

E.g. this will work.

func _ready() -> void:
    var callable = Callable(self, "hello")
    story.BindExternalFunction("hello", callable)

func hello() -> void:
    pass

But this won't.

func _ready() -> void:
    var callable = Callable(self, "hello").bind("Hello World!")
    story.BindExternalFunction("hello", callable)

func something(message: String) -> void:
    pass
Clone this wiki locally