Sharing code between multiple projects

Godot Version

4.5.1

Question

I’m making a game, and I’m making a level editing tool.

The editing tool essentially edits text files that the engine can read to produce a level.

I’d like for the tool to have a button that will let it run the new level in the same engine as the game.

I’d kind of like the editing tool to be easily separated from the game engine so I can use it for other projects.

How can I make sure both of these projects, the game and the editor, use the same codebase for the engine?

Or am I better off keeping them both in the same project, and somehow specifying two different releases?

You will need Godot specific code for the game engine to understand your text level format. Unless your tool is writing Godot’s .tscn/.tres format directly.

To start the Level you could spawn a Godot process targeting a scene with that level open, godot or godot.exe (if on windows) accepts tscn files to open immediately.

I understand that. Pretend I have an engine in the main game that happily reads and loads from the text format.

How can I have both projects running the same set of scenes and suchlike, so when changes are made in the game project, those changes are also ‘made‘ in the tool project?

I’m interested in avoiding a workflow like
run tools>edit level in tool>save in tools>open game in editor>load new level>playtest game> close game and return to tools>repeat

in favor of
run tools>edit level>test level within tools>edit level again>etc> save level

Ideally I’d be able to hand the tools.exe to someone who doesn’t have godot or even a copy of the main game and let them work on levels for it.

Implement the tool as a plugin.

1 Like

This is what I described, you could have a button in your tool that just plays the level in Godot without any level picking fuss. If someone doesn’t have Godot installed then there is no way to accurately playtest the game, since they do not have the engine, this is not a use case you should attempt to support. “LibGodot” is in the works, but if you are linking Godot to your level editor you might as well make it a plugin instead for significantly less work.

Totally possible, they just wouldn’t be able to playtest without the game/editor as should be expected.


I’m getting confused, what are the “both projects” versus the “game project”, “main game”, and “tool project”? Do you want players in-game changes to write level data to your level editing tool? I suppose it depends on the kind of game you are making, like in Minecraft players can dig and place blocks while the tool “World Edit” can open their “levels” and edit them all the same, without Minecraft installed. But I’d call it a save editor or world editor not a level editor, more of a semantic confusion if I understand correctly.

The game project is Neverwinter Nights.
The tool project is the Aurora Toolset.

I want to be able to give my creative team the toolset without them having to install the Godot editor (indeed, long term the toolset would be released publicly as a modding tool). And when the programmers push a major update to the main game engine, I want to be able to compile an update to the toolset with minimal fuss.

If it really is a terrible idea to separate it into two projects, how would I go about producing the two different executables from the same project? It seems like export presets will do this, but it also looks like they function on a whitelist and need to be recreated if new files are added…

(I don’t really get why you think it’d be impossible to playtest without the entire main game and Godot. You’d need the game engine code, sure, but there is no reason to pack the entire main campaign, all the art assets, the save load system the main menu, etc. into a level editor. Just the code that handles loading a level from the level definition. The ability to reference art assets from the main project would be useful sure, but to be an editing tool it’ll need an asset import system anyway.)

Develop all of the toolset functionality as a Godot plugin. Let that plugin be a separate project.

You can now:

  • plug the plugin into a new standalone toolset project.
  • plug the plugin into the game project to integrate the toolset with the game.

That’s the main point I’m talking about, you need the game engine code and it’s significantly less work if there is only one game engine code set, sure your art and levels can be separate, saving/loading is a bad example though that should be part of the engine and could be useful when level testing. The Aurora Toolset also requires NWN to test levels, it doesn’t have truly built-in play testing, it just launches NWN.exe with some parameters similar to my original recommendation.

I’m not sure how Godot fits into your project or where your project fits between these two, but it seems like you should just use NWN to playtest if you are making a NWN mod or expanding on their tools. It may help if you explained the big picture, what are you trying to do exactly?

Tell me more about plugins. Do you know a good tutorial on them?

Here’s a good start

1 Like