Modularity
Module loading, initialization, and lifecycle management system for the Lilia framework.
Overview
lia.module.load(uniqueID, path, variable, skipSubmodules)
Purpose
Loads and initializes a module from a specified directory path with the given unique ID.
When Called
Called during module initialization to load individual modules, their dependencies, and register them in the system.
Parameters
string uniqueID The unique identifier for the module.
string path The file system path to the module directory.
string, optional variable The global variable name to assign the module to (defaults to "MODULE").
boolean, optional skipSubmodules Whether to skip loading submodules for this module.
Example Usage
-- Load a custom module
lia.module.load("mymodule", "gamemodes/my_schema/modules/mymodule")
lia.module.initialize()
Purpose
Initializes the entire module system by loading the schema, preload modules, and all available modules in the correct order.
When Called
Called once during gamemode initialization to set up the module loading system and load all modules.
Example Usage
-- Initialize the module system (called automatically by the framework)
lia.module.initialize()
lia.module.loadFromDir(directory, group, skip)
Purpose
Loads all modules found in the specified directory, optionally skipping certain modules.
When Called
Called during module initialization to load groups of modules from directories like preload, modules, and overrides.
Parameters
string directory The directory path to search for modules.
string group The type of modules being loaded ("schema" or "module").
table, optional skip A table of module IDs to skip loading.
Example Usage
-- Load all modules from the gamemode's modules directory
lia.module.loadFromDir("gamemodes/my_schema/modules", "module")
lia.module.get(identifier)
Purpose
Retrieves a loaded module by its unique identifier.
When Called
Called whenever code needs to access a specific module's data or functions.
Parameters
string identifier The unique identifier of the module to retrieve.
Returns
table or nil The module table if found, nil if the module doesn't exist.
Example Usage
-- Get a reference to the inventory module
local inventoryModule = lia.module.get("inventory")
if inventoryModule then
-- Use the module
end