Vital.sandbox
File

file.read

Shared

Reads the content of a specified file


Syntax

local content = file.read(path)

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 read

Returns

TypeNameDescription
string / boolcontentFile's content on successful execution, or false on failure

Examples

Read a file within the current resource
engine.print("info", "File content:", file.read("files/data.json"))
Read a file from another running resource
engine.print("info", "File content:", file.read(":resource_a/files/data.json"))

On this page