Skip to content
ConcordConcordConcord

World:query

Queries flushed Entities against a Filter definition.

← World

Queries flushed Entities against a Filter definition.

Pending (not yet flushed) additions are not included. Component changes on already flushed Entities are visible immediately.

world:query( def, onMatch )

Pass a function as onMatch. It is called once per matching Entity. Nothing is returned.

Name Type Description
def FilterDefinition Filter definition (component names, with ! prefix to reject)
onMatch fun(e: Entity) Callback for each match, or a table to fill

matches = world:query( def, onMatch )

Collect matches into a table and return it. onMatch is optional; when omitted, a new empty table is used.

Name Type Description
def FilterDefinition Filter definition (component names, with ! prefix to reject)
onMatch? table? Callback for each match, or a table to fill
Name Type Description
matches table The list of matches, or nil if onMatch was a callback