ludic/ns-query.html
2026-09-17 22:10:03 +00:00

22 lines
No EOL
3.1 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Query — Ludic</title>
<meta name="description" content="Spatial and set queries over the live entities that carry a property, built on the World reflection ABI.">
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="docs.css">
</head>
<body>
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
<main class="wrap item">
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <span class="here">Query</span></div>
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Query</h1></div>
<p class="ns-blurb">Spatial and set queries over the live entities that carry a property, built on the <a href="world"><code>World</code></a> reflection ABI. <a href="query-count"><code>Query.count</code></a> and <a href="query-first"><code>Query.first</code></a> ask how many bearers there are and which is first; <a href="query-nearest"><code>Query.nearest</code></a> and <a href="query-within"><code>Query.within</code></a> 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 <a href="world-prop_id"><code>World.prop_id</code></a> and a field id from <a href="world-field_id"><code>World.field_id</code></a>. 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 <code>Query.*</code> gets the reflection ABI emitted automatically, no <code>@event</code> required.</p>
<div class="ns-methods"><a class="ns-method" href="query-count.html"><code class="nm-sig">Query.count(prop) -&gt; int</code><span class="nm-tip">How many live entities carry a property.</span></a><a class="ns-method" href="query-first.html"><code class="nm-sig">Query.first(prop) -&gt; int</code><span class="nm-tip">The lowest-id live entity carrying a property, or -1.</span></a><a class="ns-method" href="query-nearest.html"><code class="nm-sig">Query.nearest(prop, pos, x_field, y_field, x, y) -&gt; int</code><span class="nm-tip">The bearer of prop closest to a point, by squared distance.</span></a><a class="ns-method" href="query-within.html"><code class="nm-sig">Query.within(prop, pos, x, y, radius, x_field, y_field) -&gt; []int</code><span class="nm-tip">Every bearer of prop inside a radius of a point.</span></a></div>
<a class="back" href="api.html">← All symbols</a>
</main>
<script src="ludic-highlight.js"></script>
<script>Ludic.installCards(); Ludic.flashTarget();</script>
</body></html>