Skip to main content

ModLoader

See the code at autoload/mod_loader.gd

Description

Inherits Node

The ModLoader class is a singleton responsible for loading mods. Upon game start, this class:

  1. Recursively searches for mod files (*.mod.tres or *.mod.json files) within the directories specified in the ProjectSettings."mod_system/mod_paths" property
  2. Loads the mods it found
  3. Communicates with ModSystem to install them using the ModSystem.install() method.

The ModLoader class is designed to work in conjunction with the ModSystem class, which manages the overall functionality and behavior of mods in the game.


Signals

finished_loading

signal finished_loading

This signal is emitted when all mods have been loaded and installed.


Properties

is_finished_loading

var is_finished_loading: bool

If true, all mods have been loaded and installed.

Typebool
Defaultfalse

Methods

load_all_mods

func load_all_mods() -> void

Recursively finds all mod paths that end with .mod.tres, .mod.res, or .mod.json, loads them, and installs them using the ModSystem.install() method.

Returns

void


load_mod

func load_mod(path: String) -> Mod

Loads a mod at the specified path and installs it using the ModSystem.install() method.

Parameters

NameTypeDescription
pathStringThe file path of the mod to load.

Returns

TypeMod or null
DescriptionThe loaded mod.

discover_mod_paths

func discover_mod_paths(dirs: Array[String]) -> Array[String]

Recursively searches each listed directory for mods and returns a list of all paths to mods.

Parameters

NameTypeDescription
dirsArray[String]The directories to search for mod paths.

Returns

TypeArray[String]
DescriptionAll paths to mods within the listed `dirs` (recursive).