Vital.sandbox
File

file.write

Shared

Writes content to a specified file


Syntax

local status = file.write(path, content)

Prefix the path with :resourcename to access files from another running resource.

  • Local path — resolves relative to the current resource's directory
  • Cross-resource path — prefix with :resourcename to resolve relative to another running resource's directory
  • Example:resource_a/files/data.json accesses files/data.json inside resource_a

Parameters

TypeNameDescription
stringpathFile path to write the contents to
stringcontentContent to be written

Returns

TypeNameDescription
boolstatustrue on successful execution, or false on failure

Examples

Write content to a file within the current resource
engine.print("info", "File written:", file.write("files/data.json", "{}"))
Write content to a file from another running resource
engine.print("info", "File written:", file.write(":resource_a/files/data.json", "{}"))

On this page