Skip to content

Search

Documentation

assets module

Asset definitions by reference: a project path, file#entry for one entry, #id for a scene block, or id://<id> from assets/index.toml. A script gets the…

In questa pagina

Asset definitions by reference: a project path, file#entry for one entry, #id for a scene block, or id://<id> from assets/index.toml. A script gets the definition table.

11 functions, 0 constants. Scripts reach it as assets::.

Functions

Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.

function acts on what it does
assign_id(path: string) -> string — The id a file has, giving it one if it has none: a digest of the path and content, written to assets/index.toml and, for an asset document, as its top-level id. Reference it as id://<id> afterwards.
directory(type_name: string) — The project-relative directory files of an asset type belong in; empty when the type is unknown or declared none.
duplicate(reference: string) — A private copy of a definition, read past the cache, so editing it disturbs no other holder of that reference.
exists(reference: string) — Whether a reference resolves to a definition that is really there; false rather than an error when it does not.
id(path: string) -> string? — The id assets/index.toml gives a file, or nil when it has none.
invalidate() — Declare everything derived from project files stale (a shader a material links, say) so it is rebuilt from disk; for a file the watcher does not cover.
load(reference: string) — The definition table behind a reference, from the cache; an error when the reference resolves to nothing.
path(reference: string) -> string — The path an id:// reference resolves to in the running project; a path comes back as itself, and an unknown id is an error naming the index.
reload(reference: string) — Forget a reference so the next load re-reads its file, along with every entry cut from that same file.
rename(from: string, to: string) -> [string] — Move a file or directory and rewrite every reference to it in the project's .toml files, comments kept; answers the files rewritten. Paths as fs.* takes them, so an editor refactors the game it has open by absolute path. Script sources are not rewritten: a path in a .rn is the script's own value, and id:// is the reference that survives a move.
save(reference: string, definition: any) — Write a definition table to the project-relative file a reference names; an error unless it names a whole file.