Skip to content

Mod Files

KANAjetzt edited this page Aug 7, 2023 · 25 revisions

Mods you create must have the following 2 files:

  • mod_main.gd - The init file for your mod
  • manifest.json - Meta data for your mod

mod_main.gd

See ModLoader-API for more info.

extends Node

const MYMODNAME_MOD_DIR = "AuthorName-ModName/"
const MYMODNAME_LOG = "AuthorName-ModName"

var dir = ""
var ext_dir = ""
var trans_dir = ""

# With ModLoader Version 6.1.0 the `modLoader` parameter has been removed.
# For more details visit: https://github.com/GodotModding/godot-mod-loader/releases/tag/v6.1.0
# func _init(modLoader = ModLoader):
func _init():
	ModLoaderUtils.log_info("Init", MYMODNAME_LOG)
	dir = modLoader.UNPACKED_DIR + MYMODNAME_MOD_DIR
	ext_dir = dir + "extensions/"
	trans_dir = dir + "translations/"

	# Add extensions
	modLoader.install_script_extension(ext_dir + "main.gd")

	# Add translations
	modLoader.add_translation_from_resource(trans_dir + "modname_text.en.translation")


func _ready():
	ModLoaderUtils.log_info("Done", MYMODNAME_LOG)

Warning: The const variable you use to log (MYMODNAME_LOG in the example above) should always be unique to your own mod, in every file you use it. Otherwise, if another mod uses that same variable, you'll get an error.

manifest.json

{
	"name": "ModName",
	"namespace": "AuthorName",
	"version_number": "1.0.0",
	"description": "Mod description goes here",
	"website_url": "https://github.com/example/repo",
	"dependencies": [
		"Add IDs of other mods here, if your mod needs them to work"
	],
	"extra": {
		"godot": {
			"incompatibilities": [
				"Add IDs of other mods here, if your mod conflicts with them"
			],
			"authors": ["AuthorName"],
			"compatible_mod_loader_version": ["3.0.0"],
			"compatible_game_version": ["0.6.1.6"],
			"config_defaults": {}
		}
	}
}

💡 Tip: This uses the structure of Thunderstore packages, which means you can use the same manifest.json for both your mod and your Thunderstore package.

Tips & Best Practices

GDScript has a style guide you can read here. Following the guide will help your code be more consistent, and make it easier to maintain and expand by other modders.

When naming files, use snake_case, and only use the characters A-z, 0-9, and _.

Note: ModLoader mods use hyphens (-) for mod names, but they shouldn't be used in any other case.

Next: API Methods

Clone this wiki locally