DirkScripts
Docs
Require
βΉοΈ Shared Module
#lib.require
Loads, caches, and returns a module. Detects circular dependencies. Searches native require, then package.preload, then file-based loading.
lualocal utils = lib.require('utils') local remote = lib.require('@otherResource.shared.helpers')
| 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.
lualocal result = lib.load('shared/config') local bridgeResult = lib.load('bridge/keys/qbx', nil, true)
| 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.
lualocal config = lib.loadJson('config/settings')
| Parameter | Type | Required | Description |
|---|---|---|---|
| filePath | string | yes | Path to the JSON file |
#lib.loadBridge
Loads a bridge module for a specific resource and context.
lualocal keysBridge = lib.loadBridge('keys', 'qb-vehiclekeys', 'client')
| 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 |
