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
: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 write the contents to |
string | content | Content to be written |
Returns
| Type | Name | Description |
|---|---|---|
bool | status | true on successful execution, or false on failure |
Examples
engine.print("info", "File written:", file.write("files/data.json", "{}"))engine.print("info", "File written:", file.write(":resource_a/files/data.json", "{}"))