Skip to content

Establish convention for sharing libraries #62

@erodozer

Description

@erodozer

Describe the project you are working on:
This applies to any project that would like to install dependency or assets developed by others.

Describe how this feature / enhancement will help your project:
Right now there is no established convention to enforce for managing packages that may contain source code, assets, or plugins. This applies both to how people are expected to create a repository for it to be used by a Godot project, as well as where a godot project should store its downloaded modules.

Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
An example of how a project could store dependencies, as well as how those dependencies can acceptably be organized to be recognized by Godot.

project/
├── godot_modules/
│   ├── actor-module/
│   │   ├── package.json 
│   │   ├── index.gd
│   │   ├── Actor.tscn
│   │   └── placeholder.png
│   └── simple-scene-manager/
│       ├── lib/
|       |   ├── SceneManager.tscn
|       |   └── SceneManager.gd
│       ├── assets/
|       |   └── transition.png
│       └── package.json
├── assets/
└── scripts/

Describe implementation detail for your proposal (in code), if possible:
This is more of a community pattern to describe and enforce than it is an actual code feature. However, if it's properly enforced, then the engine could also start to depend on the known convention and implement custom loaders for efficient coding, such as how npm modules can be required from root level namespace instead of relative paths.

Without a properly defined convention for sharing modules, what's checked out can become messy. My least favorite pattern I see in repositories is including a subfolder in the git repo with the same name as the repo. This makes paths in code look redundant when loading, ie.

const ActorClass = preload("res://godot_modules/mymodule/mymodule/index.gd").Actor

With the ability to define packages using with a meta file and recognize the convention with the engine you could simplify this to

const ActorClass = preload("dep://mymodule").Actor

Even resources in the file browser could be organized under a new tree for dependencies, and these files can be treated as Read-Only by the editor to prevent accidental tampering. Resource Loading could be referenced with appropriate abbreviated paths too in the TSCN and TRES files.

If this enhancement will not be used often, can it be worked around with a few lines of script?:
Best solution I've found, since not everyone publishes to the Godot Asset Library, is to use git submodules. This also allows for handling any modules that a company may keep internal for personal projects.

Is there a reason why this should be core and not an add-on in the asset library?:
If leveraging a defined convention to redefine how loading is perfromed, it must be implemented at a core level to perform lookups. Using something like npm's package.json to define where "sources" or an "index" exists is helpful as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions