Skip to content

ModLoaderConfig🔗

Inherits: Object

Class for managing per-mod configurations.


Constants🔗

• LOG_NAME: "ModLoader:Config"🔗

• DEFAULT_CONFIG_NAME: "default"🔗


Method Descriptions🔗

• ModConfig  create_config( mod_id:  String, config_name:  String, config_data:  Dictionary) static🔗

Description:🔗

Creates a new configuration for a mod.

Parameters:🔗

  • mod_id (String): The ID of the mod.
  • config_name (String): The name of the configuration.
  • config_data (Dictionary): The configuration data to be stored.

Returns:


• ModConfig  update_config( config:  ModConfig) static🔗

Description:🔗

Updates an existing ModConfig object with new data and saves the config file.

Parameters:🔗

Returns:


• bool  delete_config( config:  ModConfig) static🔗

Description:🔗

Deletes a ModConfig object and performs cleanup operations.

Parameters:🔗

Returns:

  • bool: True if the deletion was successful, False otherwise.

• void  set_current_config( config:  ModConfig) static🔗

Description:🔗

Sets the current configuration of a mod to the specified configuration.

Parameters:🔗


• Dictionary  get_config_schema( mod_id:  String) static🔗

Description:🔗

Returns the schema for the specified mod id.

Parameters:🔗

  • mod_id (String): The ID of the mod.

Returns:

  • A dictionary representing the schema for the mod's configuration file.

• Dictionary  get_schema_for_prop( config:  ModConfig, prop:  String) static🔗

Description:🔗

Retrieves the schema for a specific property key.

Parameters:🔗

  • config (ModConfig): The ModConfig object from which to retrieve the schema.
  • prop (String): The property key for which to retrieve the schema.

Returns:

  • Dictionary: The schema dictionary for the specified property.

• Array  get_mods_with_config( ) static🔗

Description:🔗

Retrieves an Array of mods that have configuration files.

Returns:

  • Array: An Array containing the mod data of mods that have configuration files.

• Dictionary  get_configs( mod_id:  String) static🔗

Description:🔗

Retrieves the configurations dictionary for a given mod ID.

Parameters:🔗

  • mod_id: The ID of the mod.

Returns:

  • Dictionary: A dictionary containing the configurations for the specified mod. If the mod ID is invalid or no configurations are found, an empty dictionary is returned.

• ModConfig  get_config( mod_id:  String, config_name:  String) static🔗

Description:🔗

Retrieves the configuration for a specific mod and configuration name.

Parameters:🔗

  • mod_id (String): The ID of the mod.
  • config_name (String): The name of the configuration.

Returns:


• bool  has_current_config( mod_id:  String) static🔗

Description:🔗

Checks whether a mod has a current configuration set.

Parameters:🔗

  • mod_id (String): The ID of the mod.

Returns:

  • bool: True if the mod has a current configuration, false otherwise.

• bool  has_config( mod_id:  String, config_name:  String) static🔗

Description:🔗

Checks whether a mod has a configuration with the specified name.

Parameters:🔗

  • mod_id (String): The ID of the mod.
  • config_name (String): The name of the configuration.

Returns:

  • bool: True if the mod has a configuration with the specified name, False otherwise.

• ModConfig  get_default_config( mod_id:  String) static🔗

Description:🔗

Retrieves the default configuration for a specified mod ID.

Parameters:🔗

  • mod_id (String): The ID of the mod.

Returns:

  • ModConfig: The ModConfig object representing the default configuration for the specified mod. If the mod ID is invalid or no configuration is found, returns null.

• ModConfig  get_current_config( mod_id:  String) static🔗

Description:🔗

Retrieves the currently active configuration for a specific mod.

Parameters:🔗

  • mod_id (String): The ID of the mod.

Returns:


• String  get_current_config_name( mod_id:  String) static🔗

Description:🔗

Retrieves the name of the current configuration for a specific mod.

Parameters:🔗

  • mod_id (String): The ID of the mod.

Returns:

  • String The currently active configuration name for the given mod id or an empty string if not found.

• ModConfig  refresh_config_data( config:  ModConfig) static🔗

Description:🔗

Refreshes the data of the provided configuration by reloading it from the config file.

Parameters:🔗

Returns:

  • ModConfig: The ModConfig object with refreshed data if successful, or the original object otherwise.

• void  refresh_current_configs( ) static🔗

Description:🔗

Iterates over all mods to refresh the data of their current configurations, if available.

Returns:

  • No return value

Compares the previous configuration data with the refreshed data and emits the [signal ModLoader.current_config_changed] signal if changes are detected.
This function ensures that any changes made to the configuration files outside the application are reflected within the application's runtime, allowing for dynamic updates without the need for a restart.