library
The library namespace — 10 functions.
globals/library/has
library.has(path: string) -> boolean
Check if a library asset exists at the given path.
Parameters
pathstring— Library asset path (e.g. "@builtin/models/Sample/DamagedHelmet").
Returns boolean — True if the asset exists in the library.
assert(library.has("@builtin/models/Cube"))
globals/library/import
library.import(namespace: string, worldRef: string) -> LibraryImport
Import another world as a library under the given namespace.
Resolves the world, pins its current commit, and writes the
library marker at /source/libs/@<namespace>. Once the engine has
fetched the pinned commit, the imported tree answers to
require("@<namespace>::path"), is listed by library.list(), and
is readable under /zero/source/libs/@<namespace>/.
Parameters
namespacestring— Library namespace, with or without the leading@(e.g."@mylib"or"mylib").worldRefstring— The upstream world's guid, or its name as it appears inworld.list().
Returns LibraryImport — Record describing the import: the local name, the marker path, the upstream world_guid, and the pinned commit as version.
library.import("@mylib", "my-shared-world")
globals/library/list
library.list(assetType: string?) -> { LibraryAsset }
List all available library assets. Optionally filter by asset
type — call asset.categories() for the live set.
Parameters
assetTypestring(optional) — Asset type filter (optional).
Returns { LibraryAsset } — Array of asset descriptors. path is the @builtin::* identity, type is one of the valid type strings, format is the original file extension (e.g. "glb", "luau", "wgsl").
for _, a in ipairs(library.list("model")) do print(a.path) end
modules/library/README
require("@builtin/modules/api/engine/library") -- library (also available as global 'library')
Discover, check, and import library assets — the @builtin/* tree the engine ships and the @namespace/* trees imported from other worlds.
Usage: local library = require("@builtin/modules/api/engine/library") Also available as global: library
modules/library/has
has(path: string): boolean
Check if a library asset exists at the given path.
Parameters
pathstring— Library asset path (e.g. "@builtin/models/Sample/DamagedHelmet").
assert(library.has("@builtin/models/Cube"))
modules/library/import
import(namespace: string, worldRef: string): LibraryImport
Import another world as a library under the given namespace.
Resolves the world, pins its current commit, and writes the
library marker at /source/libs/@<namespace>. Once the engine has
fetched the pinned commit, the imported tree answers to
require("@<namespace>::path"), is listed by library.list(), and
is readable under /zero/source/libs/@<namespace>/.
Parameters
namespacestring— Library namespace, with or without the leading@(e.g."@mylib"or"mylib").worldRefstring— The upstream world's guid, or its name as it appears inworld.list().
library.import("@mylib", "my-shared-world")
modules/library/list
list(assetType: string?): { LibraryAsset }
List all available library assets. Optionally filter by asset
type — call asset.categories() for the live set.
Parameters
assetTypestring?(optional) — Asset type filter (optional).
for _, a in ipairs(library.list("model")) do print(a.path) end
typed/builtin//modules/api/engine/library/library/has
library.has(path: string) -> boolean
Check if a library asset exists at the given path.
Parameters
pathstring— Library asset path (e.g. "@builtin/models/Sample/DamagedHelmet").
Returns boolean — True if the asset exists in the library.
assert(library.has("@builtin/models/Cube"))
typed/builtin//modules/api/engine/library/library/import
library.import(namespace: string, worldRef: string) -> LibraryImport
Import another world as a library under the given namespace.
Resolves the world, pins its current commit, and writes the
library marker at /source/libs/@<namespace>. Once the engine has
fetched the pinned commit, the imported tree answers to
require("@<namespace>::path"), is listed by library.list(), and
is readable under /zero/source/libs/@<namespace>/.
Parameters
namespacestring— Library namespace, with or without the leading@(e.g."@mylib"or"mylib").worldRefstring— The upstream world's guid, or its name as it appears inworld.list().
Returns LibraryImport — Record describing the import: the local name, the marker path, the upstream world_guid, and the pinned commit as version.
library.import("@mylib", "my-shared-world")
typed/builtin//modules/api/engine/library/library/list
library.list(assetType: string?) -> { LibraryAsset }
List all available library assets. Optionally filter by asset
type — call asset.categories() for the live set.