JsonMod
See the code atresources/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.
Type | ModContentLoader |
---|---|
Default | null |
json_path
@export var json_path: String
The path to the JSON file from which this mod was created.
Type | String |
---|---|
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
Name | Type | Description |
---|---|---|
path | String | he relative path to convert to an absolute path |
Returns
Type | String |
---|---|
Description | The 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
Name | Type | Description |
---|---|---|
path | String | The path of the script to load. |
Returns
Type | ModScript |
---|---|
Description | The 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
Name | Type | Description |
---|---|---|
key | String | The key to use for the loaded asset (see ModAsset.key ). |
relative_path | String | The relative path of the asset to load. |
type | String | The type of resource to load. Can be resource or image .Defaults to resource |
Returns
Type | ModAsset |
---|---|
Description | The loaded asset. |
get_identifier
func get_identifier() -> String
Returns a string that idenitifies this mod, usually the file path. See Mod.get_identifier()
.
Returns
Type | String |
---|---|
Description | The mod's unique identifier. |