toml⚓︎
Provides support for interacting with toml data through an extended toml.lua module.
Functions⚓︎
toml.decode
⚓︎
Decode string representing toml into a table.
local result = toml.decode(input)
Parameters:
input
(string): The string to be decoded into a table.
Returns:
result
(table): The decoded table.
toml.encode
⚓︎
Encodes a table into a toml string.
local result = toml.encode(input)
Parameters:
input
(table): The table to be encoded into toml.
Returns:
result
(string): The encoded toml.
toml.loadFile
⚓︎
Loads a toml file from path
, using toml.decode
. Unlike the related json.loadfile
function, this is relative to the current working directory, and not relative to Data Files\MWSE. A file extension should be part of the path
string.
local data, error = toml.loadFile(path)
Parameters:
path
(string): The file to read from, relative to the current working directory (typically the Morrowind installation folder).
Returns:
data
(table?): The decoded data, ornil
if the file could not be found.error
(table?): Information about why the toml file could not be decoded. This result will only be given if the operation fails.
toml.loadMetadata
⚓︎
Loads a toml metadata file with a given key. This function is identical to toml.loadFile
with a mod's metadata key to determine its path. Active lua mods already have their metadata loaded, which can be retrieved using tes3.getLuaModMetadata()
.
local data = toml.loadMetadata(key)
Parameters:
key
(string): The key for the metadata. This is the prefix before-metadata.toml
, and matches a file found in Data Files.
Returns:
data
(table?): The decoded data, ornil
if the file could not be loaded.
toml.saveFile
⚓︎
Saves a serializable table to path
, using toml.encode
. Unlike the related json.savefile
function, this is relative to the current working directory, and not relative to Data Files\MWSE. A file extension should be part of the path
string.
toml.saveFile(path, data)
Parameters:
path
(string): The file to write to, relative to the current working directory (typically the Morrowind installation folder).data
(table): The data to encode and write.