Hello. I try to translate the scripts from the "bunnymark" test project into cpp scripts using GDNative. It's simple with the nodes methods, but I'm stucked on the the "preload" function. I don't know which file to include to the cpp file. I guess the problem will be the same with all GDScript methods like "print" or "randf". Thanks in advance.

a month later

Hi!

I know that you got a response on the QA, but I keep this here for future people looking for this.


load() in GDScript is just a shortcut for ResourceLoader.load(), so in the C++ bindings it's ResourceLoader::load(). (so #include <ResourceLoader.hpp>

preload() isn't really a thing in the API itself. preload() is just a command for the GDScript compiler to load() that resource while parsing your code. Because C++ is compiled ahead of time there is no real equivalent, just use ResourceLoader::load().

print() now actually is available with Godot::print(), but yes, those "special keywords/functions" in GDScript like randf aren't easily accessible in the Godot API. So we might need to create a wrapper class that contains all of those functions.

6 years later