Flecs Query
flecs_queryFind entities in a running FLECS ECS world using FLECS query syntax, returning matches with optional component values, fields, and paging.
Instructions
[READ] Find entities with a query written in the FLECS query language.
Syntax cheat sheet (terms are comma separated and all must match):
'Position, Velocity' entities with both components
'Position, !Velocity' ... without Velocity
'Position, ?Mass' Mass is optional
'Planet || Moon' either tag
'(ChildOf, Sun)' children of entity Sun
'!(flecs.core.ChildOf, *)' root entities
'(Likes, *)' / '(Likes, $x)' wildcard / variable pair target
'Position, Mass(up)' Mass on an ancestor (ChildOf)
'SpaceShip, $this ~= "Uss"' name contains "Uss"
'IsA(_, *)' instances of any prefab Use full paths (e.g. 'transform.Position') when names are ambiguous.
Returns {page, results, type_info?}. Each result has 'parent', 'name' and, depending on options, 'id', 'fields' ({values, ids, sources, is_set} per query term), 'vars' or, with table=true, 'tags'/'pairs'/'components'. page = {offset, limit, returned, may_have_more}; when may_have_more is true, call again with offset += limit. Invalid queries return the FLECS parser error (with position) so the query can be fixed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc | No | Include flecs.doc information (doc names, descriptions). | |
| limit | No | Maximum number of items to return. | |
| query | Yes | Query in the FLECS query language, e.g. 'Position, Velocity'. | |
| table | No | Return every tag, pair and component of each matched entity (same format as flecs_get_entity) instead of only the query fields. | |
| fields | No | Include per-term field data ('fields') for each result. | |
| offset | No | Number of items to skip (for paging). | |
| values | No | Include component values. | |
| inherited | No | With table=true: include components inherited from prefabs. | |
| type_info | No | Include the reflection schema of the returned components. | |
| entity_ids | No | Include numeric entity ids ('id'). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | Yes | ||
| results | Yes | ||
| type_info | No |