util.file.write
Shared
Writes content to a specified file
Syntax
local status = util.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 write |
Returns
| Type | Name | Description |
|---|---|---|
bool | status | true on successful execution, false otherwise |
Examples
core.engine.print("info", "File written:", util.file.write("files/data.json", "{}"))core.engine.print("info", "File written:", util.file.write(":resource_a/files/data.json", "{}"))