ModLoader
See the code atautoload/mod_loader.gdDescription
Inherits Node
The ModLoader class is a singleton responsible for loading mods. Upon game start, this class:
- Recursively searches for mod files (
*.mod.tresor*.mod.jsonfiles) within the directories specified in theProjectSettings."mod_system/mod_paths"property - Loads the mods it found
- Communicates with
ModSystemto install them using theModSystem.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.
| Type | bool |
|---|---|
| Default | false |
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
| Name | Type | Description |
|---|---|---|
path | String | The file path of the mod to load. |
Returns
| Type | Mod or null |
|---|---|
| Description | The 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
| Name | Type | Description |
|---|---|---|
dirs | Array[String] | The directories to search for mod paths. |
Returns
| Type | Array[String] |
|---|---|
| Description | All paths to mods within the listed `dirs` (recursive). |