yaml
Functions:
get
yaml.get(path: string, key: string): any
Name
Type
Description
path
string
Path
key
string
Key to retrieve
Returns the corresponding value, which can be a string, number, boolean, or a table (for YAML lists).
set
yaml.set(path: string, key: string, value: any): boolean
Name
Type
Description
path
string
Path
key
string
Key to retrieve
value
any
Value to set
Sets and saves the value of a key in the specified YAML file. Returns false on failure.
Example:
files.create_file("config.yml")
yaml.set("config.yml", "npc.name", "Steve")
local name = yaml.get("config.yml", "npc.name")
print(name) -- prints "Steve"yaml.set("config.yml", "npc.level", 42)
yaml.set("config.yml", "npc.hp", 99.5)
local level = yaml.get("config.yml", "npc.level")
local hp = yaml.get("config.yml", "npc.hp")
print(level) -- prints 42
print(hp) -- prints 99.5yaml.set("config.yml", "debug_mode", false)
local debug = yaml.get("config.yml", "debug_mode")
if debug then
print("Debug mode is enabled")
endyaml.set("config.yml", "npc.items", { "sword", "shield", "apple" })
-- In the YAML file, it looks like this:
-- npc:
-- items:
-- - sword
-- - shield
-- - apple
local items = yaml.get("config.yml", "npc.items")
for i, item in ipairs(items) do
print(i, item)
end
-- prints:
-- 1 sword
-- 2 shield
-- 3 appleLast updated
