Skip to main content

Mod

See the code at resources/mod.gd

Description

Inherits Resource

The Mod class represents a mod in the Mod System. It extends the Resource class and provides metadata, assets, and functionality for granting and revoking the mod to/from game objects.


Signals

installed

signal installed

This signal is emitted when the mod is installed with ModSystem.


uninstalled

signal uninstalled

This signal is emitted when the mod is uninstalled from ModSystem.


enabled

signal enabled

This signal is emitted when the mod is enabled.


disabled

signal disabled

This signal is emitted when the mod is disabled.


granted

signal granted(instance: ModInstance)

This signal is emitted when the mod is granted to an object.

Parameters

NameTypeDescription
ModInstanceThe granted mod instance.

revoked

signal revoked(instance: ModInstance)

This signal is emitted when the mod is revoked from an object.

Parameters

NameTypeDescription
ModInstanceThe revoked mod instance.

Properties

requires_restart

var requires_restart: bool

A flag indicating whether the mod requires a game restart to take effect.

Typebool
Defaultfalse

is_cheat

var is_cheat: bool

A flag indicating whether the mod provides cheats or cheat-like functionality.

Typebool
Defaultfalse

grantable_owners

var grantable_owners: PackedStringArray

An array of registered class names that can receive this mod.

TypePackedStringArray
DefaultPackedStringArray([])

instance_script

var instance_script: ModScript

The script to be run when the mod is granted to an object.

TypeModScript
Defaultnull

assets

var assets: Array[ModAsset]

An array of mod assets associated with the mod.

TypeArray[ModAsset]
Default[]

name

var name: String

The name of the mod.

TypeString
Default

author

var author: String

The author of the mod.

TypeString
Default

version

var version: String

The version of the mod.

TypeString
Default

url

var url: String

The URL where the mod can be downloaded or accessed.

TypeString
Default

thumbnail

var thumbnail: Texture2D

A thumbnail image representing the mod.

TypeTexture2D
Defaultnull

instances

var instances: Dictionary[Object, ModInstance]

A dictionary that maps objects to their corresponding mod instances.

TypeDictionary[Object, ModInstance]
Default{}

is_enabled

var is_enabled: bool setget

A computed property indicating whether this mod is currently enabled.

Typebool
Default

Methods

grant

func grant(owner: Object) -> void

Grants the mod to the specified object. This method creates a mod instance for the specified object and emits the granted signal

Parameters

NameTypeDescription
ownerObjectThe object to grant the mod to.

Returns

void


revoke

func revoke(owner: Object) -> void

Revokes the mod from the specified object. This method removes the mod instance associated with the specified object and emits the revoked signal.

Parameters

NameTypeDescription
ObjectThe object to revoke the mod from.

Returns

void


get_instance

func get_instance(owner: Object) -> ModInstance

Retrieves the mod instance associated with the specified object. If no instance exists, it returns null.

Parameters

NameTypeDescription
ownerObjectThe object to retrieve the mod instance for.

Returns

TypeModInstance
DescriptionTThe mod instance associated with the object, or null if no instance exists.

get_asset

func get_asset(key: String) -> ModAsset

Retrieves a mod asset by its key. This method searches the assets array and returns the mod asset with the matching key. If no asset is found, it returns null.

Parameters

NameTypeDescription
keyStringThe key of the asset to retrieve.

Returns

TypeModAsset
DescriptionThe mod asset with the specified key, or null if not found.

_on_installed

func _on_installed() -> void

This method is called when the mod is installed with ModSystem.

Note: This method is intended to be overridden by subclasses to perform additional actions when the mod is installed.

Returns

void


_on_uninstalled

func _on_uninstalled() -> void

This method is called when the mod is uninstalled from ModSystem.

Note: This method is intended to be overridden by subclasses to perform additional actions when the mod is uninstalled.

Returns

void


_on_enabled

func _on_enabled() -> void

This method is called when the mod is enabled.

Note: This method is intended to be overridden by subclasses to perform additional actions when the mod is enabled.

Returns

void


_on_disabled

func _on_disabled() -> void

This method is called when the mod is disabled.

Note: This method is intended to be overridden by subclasses to perform additional actions when the mod is disabled.

Returns

void


get_identifier

func get_identifier() -> String

Retrieves the unique identifier of the mod. This method returns a unique identifier for the mod, which can be used to differentiate it from other mods.

Returns

TypeString
DescriptionThe mod's unique identifier.