toml
The toml namespace: 6 functions.
globals/toml/encode
toml.encode(root: { [string]: any }) -> string
Encode a Luau table as canonical TOML bytes. Top-level string-keyed sub-tables become section headers ([name]); deeper string-keyed tables become dotted sections ([a.b]). A sequence whose every element is a non-empty string-keyed table becomes one [[a.b]] block per element, after the section's scalars. Other sequence tables are emitted as inline arrays, and string-keyed tables in value position (inside an array or a block) as inline tables ({ k = v }). Section + key order is alphabetical so the same input always produces the same bytes.
Parameters
root{ [string]: any }— The table to encode. Must be string-keyed at the root.
Returns string — A TOML-formatted string suitable for vfs.write.
local body = toml.encode({ render = { culling_mode = "gpu" } })
globals/toml/parse
toml.parse(src: string) -> { [string]: any }
Parse a TOML document into a nested Luau table. Sections ([a.b]) become nested tables; key/value pairs become entries on the current section (or root if before any section header). Arrays of tables ([[a.b]]) become sequences of tables, one per block, and a section after a block ([a.b.c]) is a sub-table of that block's row. Throws with the line number on syntax errors.
Parameters
srcstring— TOML source bytes as a string.
Returns { [string]: any } — The parsed root table. Sub-tables are plain Luau tables; arrays are 1-indexed sequence tables.
local t = toml.parse('[a]\nx = 1\ny = "hi"\n')
globals/toml/replaceArrayTables
toml.replaceArrayTables(src: string, name: string, rows: { { [string]: any } }) -> string
Replace every [[name]] block in a TOML document with rows. A block
is its [[name]] header and the lines after it up to the next header
that is neither [name.…] nor [[name.…]] — those sub-tables go with
their row. Comment lines between a block's last key and the header that
ends it stay, with that header; a line inside a multi-line array value
belongs to that value. Every line outside the blocks is kept byte for
byte, including its line ending. When nothing is removed and rows is
empty the document is returned unchanged; otherwise blank lines at the
end are dropped, and each row is appended as a [[name]] block after
one blank line, in the document's own line ending (CRLF when it uses
CRLF).
Parameters
srcstring— The document's text.namestring— The top-level array-of-tables name, e.g. "presets".rows{ { [string]: any } }— The rows, each a string-keyed table.
Returns string — The new document text.
local path = "/zero/source/.world_settings"
typed/builtin//modules/toml/toml/encode
toml.encode(root: { [string]: any }) -> string
Encode a Luau table as canonical TOML bytes. Top-level string-keyed sub-tables become section headers ([name]); deeper string-keyed tables become dotted sections ([a.b]). A sequence whose every element is a non-empty string-keyed table becomes one [[a.b]] block per element, after the section's scalars. Other sequence tables are emitted as inline arrays, and string-keyed tables in value position (inside an array or a block) as inline tables ({ k = v }). Section + key order is alphabetical so the same input always produces the same bytes.
Parameters
root{ [string]: any }— The table to encode. Must be string-keyed at the root.
Returns string — A TOML-formatted string suitable for vfs.write.
local body = toml.encode({ render = { culling_mode = "gpu" } })
typed/builtin//modules/toml/toml/parse
toml.parse(src: string) -> { [string]: any }
Parse a TOML document into a nested Luau table. Sections ([a.b]) become nested tables; key/value pairs become entries on the current section (or root if before any section header). Arrays of tables ([[a.b]]) become sequences of tables, one per block, and a section after a block ([a.b.c]) is a sub-table of that block's row. Throws with the line number on syntax errors.
Parameters
srcstring— TOML source bytes as a string.
Returns { [string]: any } — The parsed root table. Sub-tables are plain Luau tables; arrays are 1-indexed sequence tables.
local t = toml.parse('[a]\nx = 1\ny = "hi"\n')
typed/builtin//modules/toml/toml/replaceArrayTables
toml.replaceArrayTables(src: string, name: string, rows: { { [string]: any } }) -> string
Replace every [[name]] block in a TOML document with rows. A block
is its [[name]] header and the lines after it up to the next header
that is neither [name.…] nor [[name.…]] — those sub-tables go with
their row. Comment lines between a block's last key and the header that
ends it stay, with that header; a line inside a multi-line array value
belongs to that value. Every line outside the blocks is kept byte for
byte, including its line ending. When nothing is removed and rows is
empty the document is returned unchanged; otherwise blank lines at the
end are dropped, and each row is appended as a [[name]] block after
one blank line, in the document's own line ending (CRLF when it uses
CRLF).
Parameters
srcstring— The document's text.namestring— The top-level array-of-tables name, e.g. "presets".rows{ { [string]: any } }— The rows, each a string-keyed table.
Returns string — The new document text.
local path = "/zero/source/.world_settings"