Data-driven code

Godot Version

4.4.1

Question

Hello godot community,

I’m trying to experiment with a data-driven approach for my game and planning to store all my unit stats and info in JSON files instead of Resources for easy modding. Here’s a snippet of how I’m structuring it:

{
	"name": "warrior",
	"hp": 0,
	"atk": 0,
	"texture":"warrior_01.png",
	"ability": [
		{
			"event": "summoned",
			"action":[
				{
					"type":"heal",
					"amt":10
				},
			]
		}
	]
}

My question revolves around handling the “texture” field. I have a few questions when I’m building my parser to load unit data.

How should load this data onto the game? Especially when it comes to loading the texture (wether loading a path string which points to the asset or loading the actual texture itself). And when I should load all my data, or load my data periodically when needed (which requires more work).
I’m not really looking for a exact solution but I’m looking around for what solutions exists for my situation.

gltf stores textures as a filepath to the image, this is certainly the easiest to implement and grasp as a modder.

Godot’s tscn format sometimes stores images or other raw byte data as Base64 strings, everything is in one file but often becomes exceedingly large, images especially go from kilobytes to megabytes in text form. It’s also one more step to encoding, thus slowing down modders a little.


I’d recommend following gltf’s way, it’s also a JSON format. In Godot you would use Image.load_from_file with the supplied path relative to the mod’s .json file.