GamesLauncherNewsDocsCommunityMy accountMy serversDownload Launcher
DocsLua scripting

Files, JSON & require

Save data to files, work with JSON and split your code into modules.

#Files

lua
local text = LoadResourceFile(GetCurrentResourceName(), 'data/players.json')
local ok   = SaveResourceFile(GetCurrentResourceName(), 'data/players.json', text)
  • Paths are relative to resources/<resource>/. .., absolute paths and : are rejected, so the functions can't reach outside the folder.
  • LoadResourceFile returns nil if the file doesn't exist.
  • SaveResourceFile creates missing folders and overwrites the file.

#JSON

lua
local s = json.encode({ gold = 100, items = { 'sword' } })
local t = json.decode(s)

#require

lua
local utils = require('utils')          -- resources/<resource>/utils.lua
local cfg   = require('lib.config')     -- resources/<resource>/lib/config.lua

#Standard libraries

All Lua 5.4 standard libraries are on: string, table, math, utf8, coroutine, os, io and debug.

Warning

io and os can reach the whole machine. Only run resources you trust, and use LoadResourceFile / SaveResourceFile for data.

Last updated 2026-12-06