Skip to content

Loader

Core loading and bootstrap helpers for Lilia files, directories, entities, updates, compatibility, and hot reload flow.


Overview

The loader library centralizes framework startup behavior under `lia.loader`. It includes Lua files in the correct realm, loads directories of Lua files, registers scripted entities, performs framework and module version checks, initializes modules during startup or reload, and loads compatibility libraries when supported addons are detected.

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

Purpose

Checks public modules, private modules, and the framework version against remote version manifests, then logs any outdated or missing version data.

Realm

Shared

Example Usage

  lia.loader.checkForUpdates()

lia.error()View Source

Purpose

Checks public modules, private modules, and the framework version against remote version manifests, then logs any outdated or missing version data.

Realm

Shared

Example Usage

  lia.loader.checkForUpdates()

lia.warning()View Source

Purpose

Checks public modules, private modules, and the framework version against remote version manifests, then logs any outdated or missing version data.

Realm

Shared

Example Usage

  lia.loader.checkForUpdates()

lia.information()View Source

Purpose

Checks public modules, private modules, and the framework version against remote version manifests, then logs any outdated or missing version data.

Realm

Shared

Example Usage

  lia.loader.checkForUpdates()

lia.bootstrap()View Source

Purpose

Checks public modules, private modules, and the framework version against remote version manifests, then logs any outdated or missing version data.

Realm

Shared

Example Usage

  lia.loader.checkForUpdates()

lia.debug()View Source

Purpose

Checks public modules, private modules, and the framework version against remote version manifests, then logs any outdated or missing version data.

Realm

Shared

Example Usage

  lia.loader.checkForUpdates()

lia.relaydiscordMessage()View Source

Purpose

Checks public modules, private modules, and the framework version against remote version manifests, then logs any outdated or missing version data.

Realm

Shared

Example Usage

  lia.loader.checkForUpdates()

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

Purpose

Runs after the database connection succeeds and database tables are loaded.

Realm

Server


DiscordRelayed(embed)View Source

Purpose

Runs after the Discord relay request has been dispatched.

Realm

Shared

Parameters

table embed The embed payload that was dispatched.


DiscordRelaySend(embed)View Source

Purpose

Runs before a Discord relay embed is dispatched through the configured webhook.

Realm

Shared

Parameters

table embed The embed payload being prepared for relay.


DiscordRelayUnavailable()View Source

Purpose

Runs when the Discord relay cannot use the CHTTP send path and falls back to the HTTP send path.

Realm

Shared


PersistenceLoad(new)View Source

Purpose

Runs after map cleanup when the `sbox_persist` console variable changes to a non-empty value.

Realm

Server

Parameters

string new The new persistence value being loaded.


PersistenceSave(old)View Source

Purpose

Runs before map cleanup when the `sbox_persist` console variable changes.

Realm

Server

Parameters

string old The previous persistence value being saved.


SetupDatabase()View Source

Purpose

Runs immediately before the server begins connecting to the configured database.

Realm

Server