Config
Module configuration lives in config.lua and is the primary customization point for server owners.
Config File Structure
lua
-- config.lua
Config = {}
-- Simple values
Config.enabled = true
Config.debug = false
Config.maxItems = 50
-- Nested tables
Config.spawn = {
x = -269.4,
y = -955.3,
z = 31.2,
heading = 205.0,
}
-- Lists
Config.allowedJobs = { 'police', 'ems', 'mechanic' }Accessing Config in Services
lua
-- config.lua values are available globally in the module scope
local max = Config.maxItems -- 50Config Defaults
Always provide sensible defaults in the config file itself. Never assume a key exists — document every option.
Documenting Config
Each module should have a docs/config.md file that documents every option. Format:
markdown
## Config.maxItems
**Type:** `number`
**Default:** `50`
**Valid range:** `1` – `500`
Maximum number of items a player can hold in this module's storage.Validating Config at Startup
lua
-- server/init.lua
function M.init(container)
assert(type(Config.maxItems) == 'number', '[my-module] Config.maxItems must be a number')
assert(Config.maxItems > 0, '[my-module] Config.maxItems must be > 0')
endEnvironment Variable Overrides
For sensitive config (API keys, secrets):
lua
Config.apiKey = GetConvar('MY_MODULE_API_KEY', '')Set in server.cfg:
ini
set MY_MODULE_API_KEY "secret-value"