World:query
Queries flushed Entities against a Filter definition.
world:query( def, onMatch )
Section titled “world:query( def, onMatch )”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.
Arguments
Section titled “Arguments”| 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 )
Section titled “matches = world:query( def, onMatch )”matches = world:query( def, onMatch )Collect matches into a table and return it. onMatch is optional; when omitted, a new empty table is used.
Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
def |
FilterDefinition | Filter definition (component names, with ! prefix to reject) |
onMatch? |
table? | Callback for each match, or a table to fill |
Returns
Section titled “Returns”| Name | Type | Description |
|---|---|---|
matches |
table | The list of matches, or nil if onMatch was a callback |