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
:resourcenameto resolve relative to another running resource's directory - Example —
:resource_a/files/data.jsonaccessesfiles/data.jsoninsideresource_a
Parameters
| Type | Name | Description |
|---|---|---|
string | path | File path to read |
Returns
| Type | Name | Description |
|---|---|---|
string / bool | content | File's content on successful execution, or false on failure |
Examples
engine.print("info", "File content:", file.read("files/data.json"))engine.print("info", "File content:", file.read(":resource_a/files/data.json"))