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

22 lines
No EOL
5.2 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>Reflect — Ludic</title>
<meta name="description" content="Runtime reflection over the world schema — inspect properties, fields, and entity state by name and by index.">
<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">Reflect</span></div>
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Reflect</h1></div>
<p class="ns-blurb">Runtime reflection over the world schema — inspect properties, fields, and entity state by name and by index. It powers the conveniences game devs consume without writing reflection code: automatic save/load, data-driven tools, and debug/inspector overlays. Enumerate with <a href="reflect-prop_count"><code>Reflect.prop_count</code></a>/<a href="reflect-prop_name"><code>Reflect.prop_name</code></a> and <a href="reflect-field_count"><code>Reflect.field_count</code></a>/<a href="reflect-field_name"><code>Reflect.field_name</code></a>/<a href="reflect-field_type"><code>Reflect.field_type</code></a>; resolve ids with <a href="reflect-prop"><code>Reflect.prop</code></a>/<a href="reflect-field"><code>Reflect.field</code></a>; read and write an entity's fields with <a href="reflect-get"><code>Reflect.get</code></a>/<a href="reflect-set"><code>Reflect.set</code></a>/<a href="reflect-has"><code>Reflect.has</code></a>; and identify its model with <a href="reflect-kind"><code>Reflect.kind</code></a>/<a href="reflect-model"><code>Reflect.model</code></a>. The metadata tables are generated at compile time (the same reflection ABI a foreign mod binds), so introspection is a table walk, not heavy runtime machinery. This is an advanced/tooling surface — most developers get its benefits through built-in features. Related: <a href="world"><code>World</code></a>, <a href="query"><code>Query</code></a>.</p>
<div class="ns-methods"><a class="ns-method" href="reflect-prop.html"><code class="nm-sig">Reflect.prop(name) -&gt; int</code><span class="nm-tip">The property id for a property name, or -1 if unknown.</span></a><a class="ns-method" href="reflect-field.html"><code class="nm-sig">Reflect.field(prop, name) -&gt; int</code><span class="nm-tip">The field id of a named field within a property, or -1.</span></a><a class="ns-method" href="reflect-prop_count.html"><code class="nm-sig">Reflect.prop_count() -&gt; int</code><span class="nm-tip">How many properties the world schema defines.</span></a><a class="ns-method" href="reflect-prop_name.html"><code class="nm-sig">Reflect.prop_name(index) -&gt; string</code><span class="nm-tip">The name of the property at an index (or "").</span></a><a class="ns-method" href="reflect-field_count.html"><code class="nm-sig">Reflect.field_count(prop) -&gt; int</code><span class="nm-tip">How many fields a property has.</span></a><a class="ns-method" href="reflect-field_name.html"><code class="nm-sig">Reflect.field_name(prop, index) -&gt; string</code><span class="nm-tip">The name of the field at an index within a property.</span></a><a class="ns-method" href="reflect-field_type.html"><code class="nm-sig">Reflect.field_type(prop, index) -&gt; string</code><span class="nm-tip">The type name of the field at an index within a property.</span></a><a class="ns-method" href="reflect-get.html"><code class="nm-sig">Reflect.get(entity, prop, field) -&gt; int</code><span class="nm-tip">Read one field of an entity by (prop, field) id.</span></a><a class="ns-method" href="reflect-set.html"><code class="nm-sig">Reflect.set(entity, prop, field, value)</code><span class="nm-tip">Write one field of an entity by (prop, field) id.</span></a><a class="ns-method" href="reflect-has.html"><code class="nm-sig">Reflect.has(entity, prop) -&gt; bool</code><span class="nm-tip">Does an entity carry a property?</span></a><a class="ns-method" href="reflect-kind.html"><code class="nm-sig">Reflect.kind(entity) -&gt; int</code><span class="nm-tip">The model id of an entity.</span></a><a class="ns-method" href="reflect-model.html"><code class="nm-sig">Reflect.model(name) -&gt; int</code><span class="nm-tip">The model id for a model name, or -1 if unknown.</span></a><a class="ns-method" href="reflect-serialize.html"><code class="nm-sig">Reflect.serialize(entity) -&gt; value</code><span class="nm-tip">Walk an entity's components into a value tree.</span></a><a class="ns-method" href="reflect-apply.html"><code class="nm-sig">Reflect.apply(entity, value) -&gt; int</code><span class="nm-tip">Write a value tree's fields back into an entity.</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>