Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sure-developer.com/llms.txt

Use this file to discover all available pages before exploring further.

Config

The config module loads Lua configuration files from the consuming resource and caches the result. It can validate loaded values with the validator module before returning them.
local config = sure.getModule('config')
local validator = sure.getModule('validator')

Load a config file

config/settings.lua
return {
  shopName = 'Sure Market',
  taxRate = 0.1,
  coords = vector3(1, 2, 3)
}
shared.lua
local schema = validator.object({
  shopName = validator.string().required(),
  taxRate = validator.number().min(0).max(1),
})

local settings = config:load('config/settings.lua', schema)
print(settings.shopName)
File paths are normalized before loading, so config/settings.lua resolves through the same module-style path as config.settings.

Cache and reload

config:load(filePath, schema?) returns the cached value after the first read. If you pass a schema later, the cached value is still validated before it is returned.
local first = config:load('config/settings.lua')
local cached = config:load('config/settings.lua')
local fresh = config:reload('config/settings.lua')

Safe environment

Config files run with a small environment that includes common Lua helpers and vector constructors.
AvailableNotes
math, table, stringStandard helper libraries.
pairs, ipairs, tonumber, tostring, typeCommon functions for building config tables.
vector3, vector4FiveM vector constructors.
A missing file raises [sure_lib][config] cannot load file: <path>. A schema failure raises [sure_lib][config] validation failed in <path>: ....