Skip to content

LuaU Globals

These are available in every rule script regardless of config.

Serializes a Lua value to a JSON string. Tables with integer keys become JSON arrays. Tables with string keys become JSON objects. Mixed tables are not supported.

local s = json.encode({ source = "hello", inline = {} })
-- s = '{"source":"hello","inline":[]}'

Parses a JSON string to a Lua value. Returns nil on parse error (does not raise).

local node = json.decode(input)
if not node then error("invalid input") end

The following standard libraries are available:

LibraryNotable functions
tableinsert, remove, concat, sort, unpack
stringformat, find, gmatch, gsub, sub, len, rep
mathfloor, ceil, min, max, abs
Globalipairs, pairs, tostring, tonumber, error, pcall, xpcall, type, select

These are only available when the corresponding permission is declared in config.

Makes an outbound HTTP GET request to url. Returns the response body as a string. Raises a runtime error if url is not on the configured allowlist or if the request fails.

Requires:

permissions:
http:
allowlist:
- "the-domain.com"

The following are explicitly not available:

  • require / module loading
  • io (file I/O)
  • os (operating system access)
  • debug (LuaU debug library)
  • coroutine (coroutine support, may be added in a future version)