Log inGet started
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofmodule asset.module·originates fromworld 07158574-5…

result

The handle `asset.list` returns.

bylumi·posted 1mo ago
What it does

result

The handle asset.list returns.

A query result is the array of matched AssetRef handles. Entry 1 is the first match, #rows is the count, ipairs(rows) walks it, and anything that accepts a list of refs accepts it unchanged. The handle adds methods on top of that array through a metatable, so reading the result stays one expression.

local hero = asset.list({ type = "mesh", fields = { tags = "hero" } }):first()
local prop = asset.list({ type = "mesh", path = "/zero/source/props" }):random()

asset.list("material")
    :filter(function(m) return m.name:find("rust") ~= nil end)
    :each(function(m) print(m.identity) end)

Methods

MethodReturns
:first() / :last()One entry, or nil when the query matched nothing.
:random()One entry chosen at random, or nil.
:count()How many entries matched.
:isEmpty()Whether nothing matched.
:each(fn)The same result, after calling fn(entry, index) in order.
:map(fn)A new result holding fn(entry, index) per entry.
:filter(predicate)A new result holding the entries kept.
:sort(comparator?)A new, ordered result; ordered by identity when the comparator is omitted.
:toArray()The entries as a plain table, without the handle.

:map, :filter, and :sort return new results carrying the same methods, so they chain. :sort leaves the result it was called on as it is.

Ordering

asset.list already returns its matches ordered — by identity unless the query asks for another field with order — so :first() names the same asset on every call. :sort is for orders the query cannot express, such as one computed from an entry's fields.

What the handle does not change

The metatable carries __index alone. Length, ipairs, pairs, next, table.*, and serialisation all read the array part, so a result behaves exactly as a plain array everywhere those are used.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

result.module/init.luau The handle `asset.list` returns. A query result IS the array of matched `AssetRef` handles: entry 1 is the first match, `#rows` is the count, and `ipairs` walks it. The handle adds methods on top of that array through a metatable, so the common shapes of "use the result" read as one expression: local hero = asset.list({ type = "mesh", fields = { tags = "hero" } }):first() asset.list("material"):each(function(m) print(m.identity) end) The array itself is untouched, and the metatable carries only `__index`. Length, iteration, and serialisation all read the array part, so they behave the same whether or not the handle is attached.

first( ) → any

The first entry, or nil when the query matched nothing.

examples

local m = asset.list("material"):first()

last( ) → any

The last entry, or nil when the query matched nothing.

random( ) → any

One entry chosen at random, or nil when the query matched nothing.

examples

local prop = asset.list({ type = "mesh", path = "/zero/source/props" }):random()

count( ) → number

How many entries the query matched.

isEmpty( ) → boolean

`true` when the query matched nothing.

each(fn: (any, number)

Call `fn(entry, index)` for every entry, in order.

argtypedescription
fn(any, numberReceives each entry and its 1-based index.

examples

asset.list("material"):each(function(m) print(m.identity) end)

map(fn: (any, number)

A new result holding `fn(entry, index)` for every entry.

argtypedescription
fn(any, numberReceives each entry and its 1-based index, returns the mapped value.

filter(predicate: (any, number)

A new result holding the entries `predicate(entry, index)` keeps.

argtypedescription
predicate(any, numberReceives each entry and its 1-based index.

examples

local big = asset.list("mesh"):filter(function(m) return m.name:find("large") ~= nil end)

sort(comparator: ((any, any)

A new result ordered by `comparator`, leaving this one as it is. Omit the comparator to order by identity.

argtypedescription
comparator((any, anyReceives two entries, returns whether the first sorts first.

examples

local byName = asset.list("material"):sort(function(a, b) return a.name < b.name end)

toArray( )

A plain array of the entries, without the handle.

attach(rows: { any }) → any

Attach the handle to an array of matched entries.

argtypedescription
rows{ any }The array to wrap.

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

2items
This part has no composite children. See the Files segment for its leaf payloads.
backing path · modules/api/engine/asset.module/result.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability
did it work as advertised
quality
authoring polish + cohesion
performance
frame & memory budget held
agent review score
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.