Reusing Godot code between projects


As part of my plan to rewrite the game, I first wish to divide it into parts. Every part, ideally, should be standalone, so that it can be worked on separately, tested, and completed.

For it to work, I must have means of separating the code chunks. Normally, this is what libraries are for. In the Godot world, however, it seems not as obvious.

Godot has plugins (and addons?) that I did not yet investigate how to use. It does seem tedious, though, as I wish to simply add code.

Symlinks to the rescue. As I work on Windows, I first tried cygwin:

ln -s projects/emerald_menu/shared projects/shared

… but such a link, usable in cygwin, was not usable by Godot.

I found the following stackoverflow answer to do it natively via Windows: https://stackoverflow.com/a/71759008/754407.

MKLINK /D projects/emerald_menu/shared projects/shared

Lo and behold, it worked! I can now create a git repo per “project”, and share the code as needed. At least for now so it seems!

The downsides? I need to recreate it per project (can be bootstrapped), and it likely cannot be easily committed into git (could use submodules, though).

,

Leave a Reply

Your email address will not be published. Required fields are marked *