Skip to Content

Permanent Mod

The PermanentMod service is responsible for discovering, identifying, and sorting mods at application startup. it is the foundation of the Gnosis Modding System, handling global state patches and asset registration.

Code path: Runtime/GnosisEngine/Source/Services/Persistent/Services/Mod/GnosisPermanentModService.cs.

State

The service discovers mods in Application.persistentDataPath/Mods/ and loads their manifests.

KeyBranchPurpose
discoveredModsInternalList of all found mod manifests.
loadedModsInternalList of successfully loaded mods, sorted by priority.

Manifest Structure (manifest.json)

manifest.json
{ "modId": "com.example.mod", "name": "My Cool Mod", "description": "Adds awesome things.", "version": "1.0.0", "author": "Gnosis Developer", "minEngineVersion": "0.1.0", "loadPriority": 10, "dependencies": [], "tags": ["VFX", "NewServices"] }

Lifecycle Actions

  1. Discovery: Scans the Mods/ folder for subdirectories containing a manifest.json.
  2. Validation: Checks minEngineVersion compatibility.
  3. Sorting: Orders mods based on loadPriority and dependencies.
  4. Data Loading:
    • Merges Data/persistent.json into the global Persistent state.
    • Processes Data/Configuration/ mappings.
    • Automatically registers I18n files from Data/Configuration/I18n/.
  5. Asset Registration: Automatically scans Assets/ for .png, .jpg (as Sprites) and .wav, .mp3, .ogg (as AudioClips).
  6. Logic Initialization: Loads Scripts/main.lua and creates an isolated Lua environment for each mod.

Events

The service publishes events related to mod loading (see GnosisModEvents in Runtime/GnosisEngine/Source/Services/Persistent/Services/Mod/GnosisModEvents.cs).

Event idRole
FACT_MODS_DISCOVEREDPublished after scanning the mods folder.
FACT_MOD_LOADEDPublished after an individual mod is successfully initialized.

Functions

FunctionParametersBehavior
GetLoadedModsReturns a list of all active mod manifests.
IsModLoadedmodIdReturns true if the specified mod is active.
CallModFunctionmodId, functionName, parametersInvokes a function in the mod’s permanent Lua environment.

Modding Overview, Ephemeral Mod.

Last updated on