Config JSON🔗
The Godot ModLoader supports config files in the JSON format.
JSON Schema🔗
Mod developers can choose to add a JSON Schema to their mod's manifest file using the extra.godot.config_schema
key.
JSON | |
---|---|
Defaults🔗
The default
key in the schema is used to generate the default config.
Unsupported Keys🔗
The following keys are part of the JSON Schema 2020-12 Draft but are currently not supported by ModLoader:
Type |
Key |
---|---|
Array | contains |
Array | minContains |
Array | maxContains |
Array | uniqueItems |
Object | patternProperties |
String | *format |
Note
The format
key has one compatible property called color
which is explained in more detail in the Additional Keys and Properties section. If you require any of these validations, please let us know by opening an issue or joining our Discord.
Additional Keys and Properties🔗
The following keys and properties are not part of the JSON Schema Draft but have been added for ease of use in ModLoader:
Type | Key | Property | Description |
---|---|---|---|
String | format | color | A hexadecimal color string in ARGB format |
Color Example🔗
JSON | |
---|---|
Learn JSON Schema🔗
For more details on how to write JSON Schemas, we recommend checking out Understanding JSON Schema.
Creating Configs🔗
Mod users can choose to create their own configs by preferably using a Config Editor UI provided by the game or a mod. If no UI is available, configs can be added by duplicating the default config file and modifying it. This is less ideal because the config is validated against the schema in the mod's manifest. Creating a valid config "by hand" requires checking the JSON Schema in the mod's manifest file.
Mod config files are stored in user://configs/{mod_id}/{config_name}.json
. If a mod has a config, there should always be the default.json
config file.
Applying Configs to Your mod🔗
You can retrieve the current config for your mod by calling ModLoaderConfig.get_current_config("your_mod_id")
, which returns a ModConfig
Resource.
A ModConfig
resource contains:
Property | Description |
---|---|
name | The config name |
mod_id | The mod_id this config belongs to |
schema | The schema for your configs |
data | The data this config holds |
save_path | The path where the JSON file for this config is stored |
is_valid | False if any data is invalid |
For mod developers, the data
property is the most relevant. Depending on how the config selection is implemented, you might want to check if the config is valid using is_valid
.
With all this in mind, you can add something like the following code to your mod_main.gd
ready()
function:
mod_main.gd
different_scene.gd