Skip to main content

JsonMod

See the code at resources/json_mod.gd

Description

Inherits Mod

A JsonMod resource is instantiated when a Mod is defined by a *.mod.json file.


Properties

loader

var loader: ModContentLoader

The content loader that is loading this mod.

TypeModContentLoader
Defaultnull

json_path

@export var json_path: String

The path to the JSON file from which this mod was created.

TypeString
Default

Methods

_init

func _init(json_path_value: String, json: Dictionary, loader_value := ModContentLoader.new()) -> void

Initializes the JsonMod.

to_absolute_path

func to_absolute_path(path: String) -> String

Returns an absolute file path from a path relative to json_path.

Ex.

some_asset.png becomes user://mods/my_mod/some_asset.png.

Parameters

NameTypeDescription
pathStringhe relative path to convert to an absolute path

Returns

TypeString
DescriptionThe absolute path.

load_instance_script

func load_instance_script(path: String) -> ModScript

Loads a script (extending ModInstanceScript) loader at the given path and returns a new ModScript.

Parameters

NameTypeDescription
pathStringThe path of the script to load.

Returns

TypeModScript
DescriptionThe loaded script.

load_asset

func load_asset(key: String, relative_path: String, type: String) -> ModAsset

Loads an asset at relative_path using loader at the given path and returns a new ModAsset.

Parameters

NameTypeDescription
keyStringThe key to use for the loaded asset (see ModAsset.key).
relative_pathStringThe relative path of the asset to load.
typeStringThe type of resource to load. Can be resource or image.

Defaults to resource

Returns

TypeModAsset
DescriptionThe loaded asset.

get_identifier

func get_identifier() -> String

Returns a string that idenitifies this mod, usually the file path. See Mod.get_identifier().

Returns

TypeString
DescriptionThe mod's unique identifier.