Hey there, I've written a simple plugin for godot nativescript and then wanted to use it in the engine. First I wasn't able to find it in the "add node" Dialog, then decided to go for a simple Node and attach my plugin as a script (via a .gdns file). This does work and so I proceeded. After a while I wanted to get a simple reference to my script object and got it, but not as strict type. Due to a hint on discord I was able to create an "alias" like const MyClass = preload("res://..../*gdns) and were now able to strict type my reference.

Some time later I was wondering how to extend my script via GDScript and here I am (since extends must be the first statement, the preload hack won't work).

I have actually no clue, what I'm doing wrong, as I'm not able to access my gdnative class properly. My .gdns file looks like that:

[gd_resource type="NativeScript" load_steps=2 format=2]

[ext_resource path="res://bin/TheGuild++_Plugin.gdnlib" type="GDNativeLibrary" id=1]

[resource]
resource_name = "ProductionNode"
class_name = "ProductionNode"
library = ExtResource( 1 )

The corresponding gdnlib looks like that:

[general]

singleton=false
load_once=false
symbol_prefix="godot_"
reloadable=true

[entry]

X11.64="res://bin/x11/TheGuild++_Plugin.so"
Windows.64="res://bin/win64/TheGuild++_Plugin.dll"
OSX.64="res://bin/osx/TheGuild++_Plugin.dylib"

[dependencies]

X11.64=[  ]
Windows.64=[  ]
OSX.64=[  ]

Thanks in advance

Hi,

So the issue is actually you want to extend your gdnative script from gdscript?

I haven't used gdnative yet, but if hack with const MyClass = preload("res://..../*gdns) works maybe you should try just: extends "res://..../*gdns" as I remember it is possible to extend scripts like that, not sure about gdnative though.

@GlyphTheWolf said: Hi,

So the issue is actually you want to extend your gdnative script from gdscript?

I haven't used gdnative yet, but if hack with const MyClass = preload("res://..../*gdns) works maybe you should try just: extends "res://..../*gdns" as I remember it is possible to extend scripts like that, not sure about gdnative though.

Well, actually I would like to use my class in Editor as any other built-in class.

I gave your suggestion a try, but unfortunately it doesn't seem to work.

If you want to create a node that exists in editor like any other you'll likely have to make it either a plugin/addon or create a straight C/C++ module.

@Megalomaniak said: If you want to create a node that exists in editor like any other you'll likely have to make it either a plugin/addon or create a straight C/C++ module.

Isn't that exactly what I'm doing here (a plugin)? But anyways. Is there any way to make such a class from my Plugin extensible via GDScript without changing the workflow? If not, how could I achieve this?

I found something like that said on github:

Unfortunately GDScript can only inherit from other GDScript files. That means You can't make a VisualScript base, a C# base or a NativeScript base. There's not much we can do here :/

That's from 2019 year so not sure if that is still true, but you can check out that issue: https://github.com/godotengine/godot-cpp/issues/291

@DNKpp said: Isn't that exactly what I'm doing here (a plugin)? Judging from above github issue "module" and "gdnative plugin" are two different things.

@GlyphTheWolf said: I found something like that said on github:

Unfortunately GDScript can only inherit from other GDScript files. That means You can't make a VisualScript base, a C# base or a NativeScript base. There's not much we can do here :/

That's from 2019 year so not sure if that is still true, but you can check out that issue: https://github.com/godotengine/godot-cpp/issues/291

@DNKpp said: Isn't that exactly what I'm doing here (a plugin)? Judging from above github issue "module" and "gdnative plugin" are two different things.

Thank you for the reference. Than it seems I have to workaround this or switch over to modules (which I honestly do not want to). But there is still one unanswered question, which is also part of that issue: https://github.com/godotengine/godot-cpp/issues/291#issuecomment-490443372 If I understand him correctly he says, that I could reference my class via the name given in "class_name" property, which in my case also doesn't work. How is that supposed to work? And if it doesn't work like he explains, what is this property actually used for?

Hm, about that is everything setup properly in your plugin? I'm not an expert here, but just looking at docs example I would try: 1. Make resource_name the same as *.gdnlib file name 2. Assure that class_name is the same as class name you used in your C++ code 3. Check if you used GODOT_CLASS macro with your new class in plugin 4. Assure you not forgot call godot::register_class

Also I think your class name and names in 2, 3 and 4 steps supplied should match.

That's only my guess, never used that, so I have no idea if that makes sens.

2 years later