Require
Library
Updated 2 months ago ·
v1.3.7i
Shared Module
lib.require
Loads, caches, and returns a module. Detects circular dependencies. Searches native require, then package.preload, then file-based loading.
| Parameter | Type | Required | Description |
|---|---|---|---|
| modName | string | yes | Module name. Prefix with @resourceName. to load from another resource |
Returns: module return value (cached after first load)
lib.load
Loads and runs a Lua file. Unlike require, the result is not cached — the file is executed every time.
| Parameter | Type | Required | Description |
|---|---|---|---|
| filePath | string | yes | Path to the Lua file |
| env | table | no | Custom environment for the loaded chunk |
| bridge | boolean | no | If true, returns false instead of erroring when the file is not found |
lib.loadJson
Loads and decodes a JSON file.
| Parameter | Type | Required | Description |
|---|---|---|---|
| filePath | string | yes | Path to the JSON file |
lib.loadBridge
Loads a bridge module for a specific resource and context.
| Parameter | Type | Required | Description |
|---|---|---|---|
| _type | string | yes | Bridge category (e.g. 'keys', 'fuel', 'inventory') |
| resource | string | yes | Target resource name |
| _context | string | yes | 'client' or 'server' |
Loads from @dirk_lib.bridge.{_type}.{resource}.{_context}. Returns {} if the bridge file is not found.
Package System
The module system provides a package table compatible with Lua conventions:
| Field | Description |
|---|---|
package.path | './?.lua;./?/init.lua' |
package.preload | Table for pre-registered modules |
package.loaded | Read-only view of the module cache |
package.searchpath(name, path) | Searches for a file matching the template pattern |
Was this page helpful?
This page was last updated on 12 March 2026