Modularity Library
Module loading, initialization, and lifecycle management system for the Lilia framework.
Overview
The modularity library provides comprehensive functionality for managing modules in the Lilia framework. It handles loading, initialization, and management of modules including schemas, preload modules, and regular modules. The library operates on both server and client sides, managing module dependencies, permissions, and lifecycle events. It includes functionality for loading modules from directories, handling module-specific data storage, and ensuring proper initialization order. The library also manages submodules, handles module validation, and provides hooks for module lifecycle events. It ensures that all modules are properly loaded and initialized before gameplay begins.
lia.module.load(uniqueID, path, variable, skipSubmodules)
Loads and initializes a module from a specified directory path with the given unique ID.
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()
Initializes the entire module system by loading the schema, preload modules, and all available modules in the correct order.
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)
Loads all modules found in the specified directory, optionally skipping certain modules.
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)
Retrieves a loaded module by its unique identifier.
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