module
Lapis::Docs::F_SCRIPTING_AND_INTEROPERABILITY::B_GDSCRIPT_INTEROP
Overview
GDScript Interoperability & Project Bindings
Comprehensive guide to calling GDScript functions from Crystal, invoking Crystal methods
from GDScript, and generating strongly-typed wrappers for custom project nodes with lapis bind.
Executive Summary & Key Topics
| Topic | Method / Anchor | Description |
|---|---|---|
| Interoperability Modalities | .topic_00_interop_modes |
Dynamic reflection calls vs compile-time strongly-typed project bindings. |
| Automated Typed Project Bindings (lapis bind) | .topic_01_typed_project_bindings |
Generating strongly-typed Crystal wrappers for GDScript custom nodes. |
Related Guides & Source References
- Project Bindings Generator:
tools/lapis/src/commands/bind/project.cr - Live Specs:
spec/suites/test_gdscript_interop.cr
Defined in:
libgodot/docs/f_scripting_and_interoperability/b_gdscript_interop.crClass Method Summary
-
.topic_00_interop_modes : Nil
Interoperability Modalities: Dynamic reflection calls vs compile-time strongly-typed project bindings.
-
.topic_01_typed_project_bindings : Nil
Automated Typed Project Bindings (lapis bind): Generating strongly-typed Crystal wrappers for GDScript custom nodes.
Class Method Detail
Interoperability Modalities: Dynamic reflection calls vs compile-time strongly-typed project bindings.
Key Topics & Information
- Dynamic calls: node.call("my_method", *args) with Variant marshaling
- Strongly-typed project bindings: Generated Crystal classes for all project GDScript scripts
- Cross-language signals: Subscribing to GDScript signals in Crystal and vice versa
Automated Typed Project Bindings (lapis bind): Generating strongly-typed Crystal wrappers for GDScript custom nodes.
When you run:
lapis bind
Lapis inspects all .gd scripts in your project and generates typed Crystal wrapper classes under src/generated/project_nodes/.
Calling GDScript from Crystal:
# Strongly typed GDScript interop:
inventory = get_node("Inventory").as(GDScript::InventorySystem)
inventory.add_item("potion_health", 5) # Type-checked at compile time!
Calling Crystal from GDScript:
var player = $Player # Crystal node registered in ClassDB
player.take_damage(25) # Calls Crystal def take_damage directly!