Hacker News new | ask | show | jobs
by stateoff 3008 days ago
(Please correct me if any of the following is imprecise, as I am not a core dev of Godot)

Languages are roughly stacked like this:

1. Internal scripting

Godot internally (C++ source) makes a distinction between core and modules. So many of the functionality that do not necessarily belong to the core engine are modules.

You are free to write your own extension to and modules to the editor (for example custom Node types). There is also an EditorPlugin API so you do not necessarily have to get your hands wet in the engine API itself if not necessary. Btw. the latter API is also exposed in GDScript.

Anything that implements script_language.h as a module is considered part of the editor (e.g. exposed in-editor script support etc.)

In 3.0 that would be GDScript and C#.

2. GDNative

Additionally 3.0 introduced GDNative which in essence is an API that exposes the internal C++ API that makes up the In-Game scripting as C symbols. This has the benefit that C can be bound to anything. Going this route even the C++ API is bindings created through C :-). More details here [1].

It is a relatively new effort but so far the following languages are supported (not making claims about stability/maturity here):

- C (just the API itself via the shipped headers)

- C++ [2]

- D [2]

- Rust [2]

- Python [3]

- Nim [4]

- Possibly others?

Once you have a library that can be hooked into you load it in the editor for each individual platform you try to target.

That being said: There is no heavy boilerplate-magic going on. I've setup a CMake file to handle C++ plugins without big issues. There is no real hot-loading AFAIK but you do not need to restart the editor since it loads the libraries in play mode.

This is a sample of the GDNative API [5].

Here is a manual setup with C [6]. While the tooling improved meanwhile (e.g. in editor tools to set the libraries) it gives you a good overview how the GDNative API works.

Hope that makes sense.

[1] GDNative Architecture https://godotengine.org/article/look-gdnative-architecture

[2] Main GDNative Language Bindings https://github.com/GodotNativeTools

[3] Python via GDNative https://github.com/touilleMan/godot-python

[4] Nim via GDNative https://github.com/pragmagic/godot-nim

[5] GDNative C++ API Sample https://github.com/GodotNativeTools/godot-cpp#creating-simpl...

[6] C example of GDNative (Godot Docs) http://docs.godotengine.org/en/3.0/tutorials/plugins/gdnativ...

1 comments

I wonder if one could couple it to Swift.