readfile(path) / readfileasync(path)
Reads a workspace file; readfileasync yields while the read runs in a deferred task.
Syntax
readfile(path: string) -> string
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | Workspace-relative path. |
Returns
| Type | Description |
|---|---|
string | File contents. |
Description
readfile is synchronous and throws when the file does not exist.
Logic change: readfileasync now schedules readfile with task.defer and yields the caller until the result is ready, so background scripts can read files without blocking the current frame.
Example
writefile("notes.txt", "hello")
print(readfileasync("notes.txt"))