Loader¶
Core loading and bootstrap helpers for Lilia files, directories, entities, updates, compatibility, and hot reload flow.
Overview
lia.loader.include(path, realm)View Source
Purpose
Includes a Lua file in the requested realm and sends clientside files to clients when needed.
Realm
Shared
Parameters
string path The Lua file path to include. Backslashes are normalized to forward slashes.
string realm optional Optional realm override. Valid values are `server`, `client`, and `shared`. When omitted, the realm is inferred from filename prefixes such as `sv_`, `cl_`, or `sh_`, or from `server`, `client`, and `shared` filenames.
Example Usage
lia.loader.include("lilia/gamemode/core/libraries/config.lua", "shared")
lia.loader.include("lilia/gamemode/core/hooks/server.lua")
lia.loader.includeDir(dir, raw, deep, realm)View Source
Purpose
Includes every Lua file in a directory, optionally recursing into subdirectories.
Realm
Shared
Parameters
string dir The directory to load.
boolean raw optional When true, uses `dir` as a raw Lua path. When false or nil, resolves it relative to the active schema path while schema loading, or `lilia/gamemode` otherwise.
boolean deep optional When true, recursively loads Lua files in child folders.
string realm optional Optional realm override passed to `lia.loader.include` for every file.
Example Usage
lia.loader.includeDir("lilia/gamemode/core/libraries/thirdparty", true, true)
lia.loader.includeDir("lilia/gamemode/core/derma", true, true, "client")
lia.loader.includeGroupedDir(dir, raw, recursive, forceRealm)View Source
Purpose
Includes Lua files from a directory in sorted order while resolving each file realm from filename prefixes unless a realm override is provided.
Realm
Shared
Parameters
string dir The directory to load.
boolean raw optional When true, uses `dir` as a raw Lua path. When false or nil, resolves it relative to the active schema path while schema loading, or `lilia/gamemode` otherwise.
boolean recursive optional When true, walks child folders and loads matching Lua files from them as well.
string forceRealm optional Optional realm override for every included file. When omitted, files are resolved from `sh_`, `sv_`, `cl_`, `shared.lua`, `server.lua`, and `client.lua` names.
Example Usage
lia.loader.includeGroupedDir("modules/example/libs", false, true)
lia.loader.includeGroupedDir("lilia/gamemode/core/derma", true, true, "client")
lia.loader.checkForUpdates()View Source
lia.error(msg)View Source
Purpose
Prints a formatted error message to the console with the standard Lilia prefix.
Realm
Shared
Parameters
any msg The value to display in the error message.
Example Usage
lia.error("Failed to load character data")
lia.warning(msg)View Source
Purpose
Prints a formatted warning message to the console with the standard Lilia prefix.
Realm
Shared
Parameters
any msg The value to display in the warning message.
Example Usage
lia.warning("Using fallback inventory configuration")
lia.information(msg)View Source
Purpose
Prints a formatted informational message to the console with the standard Lilia prefix.
Realm
Shared
Parameters
any msg The value to display in the informational message.
Example Usage
lia.information("Module initialization completed")
lia.bootstrap(section, msg)View Source
Purpose
Prints a bootstrap-stage message unless a hot reload is suppressing non-reload bootstrap output.
Realm
Shared
Parameters
string section The bootstrap section label shown in the message.
any msg The value to display for the bootstrap message.
Example Usage
lia.bootstrap("Modules", "Finished loading public modules")
lia.debug()View Source
lia.relaydiscordMessage(embed)View Source
Purpose
Sends a Discord webhook embed through the configured relay endpoint and fires relay lifecycle hooks.
Realm
Shared
Parameters
table embed The Discord embed payload to send. Default title, color, timestamp, and footer values are filled in when omitted.
Example Usage
lia.relaydiscordMessage({
title = "Character Created",
description = "A new character joined the server."
})
lia.loader.includeEntities(path)View Source
Purpose
Loads and registers scripted entities, weapons, and effects from a base path.
Realm
Shared
Parameters
string path The base path containing `entities`, `weapons`, and `effects` folders.
Example Usage
lia.loader.includeEntities("lilia/gamemode")
lia.loader.includeEntities(SCHEMA.folder .. "/schema")
lia.loader.initializeGamemode(isReload)View Source
Purpose
Initializes or hot-reloads the gamemode by loading modules, formatting faction model data, refreshing reload-sensitive state, and synchronizing changed server data after reloads.
Realm
Shared
Parameters
boolean isReload optional True when initialization is being performed during a hot reload. False or nil during normal startup.
Example Usage
lia.loader.initializeGamemode(false)
lia.loader.initializeGamemode(true)
Hooks
Library-specific hooks documented for this library.
DatabaseConnected()View Source
DiscordRelayed(embed)View Source
Purpose
Runs after the Discord relay request has been dispatched.
Category
Loader
Realm
Shared
Parameters
table embed The embed payload that was dispatched.
Example Usage
hook.Add("DiscordRelayed", "liaExampleDiscordRelayed", function(embed)
print("[MyModule] handled DiscordRelayed")
end)
DiscordRelaySend(embed)View Source
Purpose
Runs before a Discord relay embed is dispatched through the configured webhook.
Category
Loader
Realm
Shared
Parameters
table embed The embed payload being prepared for relay.
Example Usage
hook.Add("DiscordRelaySend", "liaExampleDiscordRelaySend", function(embed)
print("[MyModule] handled DiscordRelaySend")
end)
PersistenceLoad(new)View Source
Purpose
Runs after map cleanup when the `sbox_persist` console variable changes to a non-empty value.
Category
Loader
Realm
Server
Parameters
string new The new persistence value being loaded.
Example Usage
hook.Add("PersistenceLoad", "liaExamplePersistenceLoad", function(new)
print("[MyModule] handled PersistenceLoad")
end)