Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensions for Godot #8505

Closed
karroffel opened this issue Apr 24, 2017 · 25 comments
Closed

Extensions for Godot #8505

karroffel opened this issue Apr 24, 2017 · 25 comments

Comments

@karroffel
Copy link
Contributor

Extensions

After talking to @touilleMan and @reduz in Paris (it was awesome!!!) I'm writing down this proposal.

GDNative is a nice way to use third party libraries in your game or just optimize performance critical code, but it could also be used to add "extensions" to Godot (for the lack of a better name, "plugin" and "add-on" are already taken 😛 )

Current situation

A GDNativeScript represents one class in a GDNativeLibrary. To have any effect, this script must be attached to any object. This is cool to write game code or wrap third party code in a class.

The current way to "extend" Godot is via plugins (or more precisely, "editor plugins"). These plugins can do a lot of awesome things, but they all only run in the editor. GDNative scripts can be used to make plugins as well, but they can't do anything that will have an impact on the running game.

Proposal

extension

Have a new project settings tab for "extensions". Extensions are GDNativeLibraries that don't need to expose any classes, they just get run and that's it.

These extensions get loaded at startup, in the editor as well as in a game.

Implementation of an extension

A regular GDNativeLibrary, but it contains a special function godot_native_extension_init and godot_native_extension_terminate that get called at startup and shutdown of Godot.

The C API (modules/gdnative/godot.h and modules/gdnative/godot/*) will contain new functions, like godot_extension_register_importer(godot_extension_importer *importer). The godot_extension_importer type would just be a struct with function pointers.

Loading and installing

A new directory called "extensions" containing subfolders for the different extension. In those folders a file "extension.cfg" or something like that. This file specifies the GDNativeLibrary to use to load the extension.

- extensions
    - fbx_loader
        - extension.cfg
        - fbx_library.tres
    - python_language
        - extension.cfg
        - python_library.tres

When the editor or game starts the extensions get loaded.

The Asset Lib could feature a new type of asset: "extension" and install that in the right place.
Once installed then the extension would get initialized, editor restart should not be required. (the Asset Lib downloader needs to initialize the initialization process 😄 )

Use cases

  • downloadable scripting languages in the AssetLib (with editor support)
  • new resource importers
  • possibly more that I can't think of right now 😄

WDYT?

@reduz
Copy link
Member

reduz commented Apr 24, 2017 via email

@reduz
Copy link
Member

reduz commented Apr 24, 2017 via email

@karroffel
Copy link
Contributor Author

Oh yeah, "GDNative submodes" sounds good!

@reduz
Copy link
Member

reduz commented Apr 24, 2017 via email

@akien-mga
Copy link
Member

Or maybe change "Plugins" to "Script plugins" and add "Native plugins"? That would be the most explicit regarding what they are, and how they are used: both can be plugged into the engine, the former are script-based and interpreted, the latter are native code.

@reduz
Copy link
Member

reduz commented Apr 24, 2017 via email

@reduz
Copy link
Member

reduz commented Apr 24, 2017 via email

@reduz
Copy link
Member

reduz commented Apr 24, 2017 via email

@karroffel
Copy link
Contributor Author

good example! "Plugins" are actually "Editor plugins", "submodules" (not that sure about the name though, of what are they a sub-part?) are not specific to the editor.

The Minecraft example could make use of a submodule because those are loaded before editor plugins are loaded.

@akien-mga
Copy link
Member

So in the end those are just pluggable "modules", as we understand the stuff in modules/. Users have already been confused by our choice of terms with modules vs plugins, so it might be a good opportunity to rethink that a bit for 3.0 :)

@reduz
Copy link
Member

reduz commented Apr 24, 2017 via email

@karroffel
Copy link
Contributor Author

sounds good to me!

I think we should choose the names carefully tough

@Zylann
Copy link
Contributor

Zylann commented Apr 24, 2017

How is this different than having a regular GDNativeLibrary having an editor version and export version? Why does it need to be a specific thing?

You said plugins can't have an impact on the game, but it's wrong. My gdscript terrain plugin is able to run both in editor and in game. The only issue I had with it is about telling Godot not to export the editor-only part.

@reduz
Copy link
Member

reduz commented Apr 24, 2017 via email

@bojidar-bg
Copy link
Contributor

What's the issue of breaking compatibility with current plugins, and shipping the more-extensible "extensions"/"plugmodules"/"native plugins" with ability to add EditorPlugin nodes and to be made with GDScript?

That way, we would not be forced to use GDNative for simple importers (e.g. of a custom text-based format), while we can still do everything from the proposal. And, as an additional plus, one would be able to even use C# for import/export/stuff!

@reduz
Copy link
Member

reduz commented Apr 24, 2017 via email

@Zylann
Copy link
Contributor

Zylann commented Apr 24, 2017

Installing addons anywhere is already a separate issue though #6023

@RameshRavone
Copy link
Contributor

Just wanted to know the status (is it being developed or dropped)

@touilleMan
Copy link
Member

@RameshRavone now that my Python binding is working, I'm going to start working on this feature

no promise on the eta though ;-)

@karroffel
Copy link
Contributor Author

@touilleMan I started laying down the basics for that on my fork, if you want you could help develop it there. I wrote you a PM on Discord about that too

@reduz
Copy link
Member

reduz commented Aug 6, 2017

how is this going?

@touilleMan
Copy link
Member

@reduz pretty well ^^

You can have a look on my fork and the corresponding Python pluginscript module.

So far I got my Pong example written in Python working 😄
I still have to bind the editor and debugger functions though.

@karroffel
Copy link
Contributor Author

This gets partially implemented by #10921, there's basically only a proper UI missing and then more APIs to actually use (like pluginscript)

@HummusSamurai
Copy link
Contributor

Closed by #11953 ?

@karroffel
Copy link
Contributor Author

Well it's more like an ongoing effort, PluginScript is only one application, GDNative singletons basically solve this issue.

But you are right, it can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants