Skip to content

Mod Files

Darkly77 edited this page Jan 30, 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 API Methods for more info.

extends Node

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

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

func _init(modLoader = ModLoader):
	ModLoaderUtils.log_info("Init", MYMODNAME_LOG)
	dir = modLoader.UNPACKED_DIR + 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 + "translations/modname_text.en.translation")


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

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": {}
		}
	}
}

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