API Reference › Query
namespace

Query

Spatial and set queries over the live entities that carry a property, built on the World reflection ABI. Query.count and Query.first ask how many bearers there are and which is first; Query.nearest and Query.within add a position — read from a coordinate property's two int fields — to find the closest entity to a point or every entity inside a radius. A property id comes from World.prop_id and a field id from World.field_id. Everything is integer and deterministic: the same world reproduces the same answers, entity order included, every run. The scan is linear over the entity table — ample for the entity counts Ludic targets — and a game that uses Query.* gets the reflection ABI emitted automatically, no @event required.

Query.count(prop) -> intHow many live entities carry a property.Query.first(prop) -> intThe lowest-id live entity carrying a property, or -1.Query.nearest(prop, pos, x_field, y_field, x, y) -> intThe bearer of prop closest to a point, by squared distance.Query.within(prop, pos, x, y, radius, x_field, y_field) -> []intEvery bearer of prop inside a radius of a point.
← All symbols