Builtin Library
README.md
references
What content of a carried mount means by the asset references it holds. A carried mount holds the closure of an asset of another world, and that content names assets the way its own world named them: by the guid, path or identity the closure states. Read at the site of the asset holding them, inside the mount, those references name the closure's own copies (each known in this session by its session guid) and the engine library at the version the closure was built against, through asset.tryResolve(ref, type, site). The open world's asset under the same guid or name is another asset.
A bundle of a carried mount composes from its template through records, and an Asset instance of it measures its overrides against the same records, so a reference the closure answers is the same value on both sides.
Exports
M.site(path, identity?) -> (site?, prefix?)- where an asset of a carried mount stands: its path in the mount (its carried identity when no path is given) and the prefix its mount spells content with (@carried.<key>::). Both nil for an asset of the open world.M.close(value, site, prefix) -> value- a copy of decoded component data with every asset-reference envelope ({ __ref, type?, name? }), at any depth, naming what the closure atsitemeans by it: the guid it resolves to there, or, while the mount answers nothing for it, the reference spelled in the mount (@carried.<key>::<reference>), which waits on the mount and applies once the mount holds the asset. A component reference (componentTypebeside__ref) stays as written.M.records(template, path, identity?) -> template- the records of an entity template as the asset atpathcomposes them: closed throughclosefor an asset of a carried mount,templateitself for an asset of the open world.
Usage
local references = require("modules.api.engine.carried.references")
local records = references.records(bundleRef:getTemplate(), bundleRef.path, bundleRef.identity)
local site, prefix = references.site(bundleRef.path, bundleRef.identity)
if site ~= nil then
local data = references.close({ material = { __ref = guid, type = "material" } }, site, prefix)
end