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

22 lines
No EOL
2.3 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>Prefab — Ludic</title>
<meta name="description" content="A prefab is a model with preset component fields — prefab Grunt: Creature { Stats { hp: 30 }, Weapon { def_id: 1 } } — spawned with spawn Grunt { Position { x:…">
<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">Prefab</span></div>
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Prefab</h1></div>
<p class="ns-blurb">A <code>prefab</code> is a model with preset component fields — <code>prefab Grunt: Creature { Stats { hp: 30 }, Weapon { def_id: 1 } }</code> — spawned with <code>spawn Grunt { Position { x: 40 } }</code>, where the spawn's own fields override the presets. Prefabs chain (<code>prefab Grunt: Foe</code>, where <code>Foe</code> is itself a prefab) so shared presets live once. <code>spawn</code> is also an expression yielding the new entity (<code>let e = spawn Grunt { … }</code>), and <a href="prefab-spawn"><code>Prefab.spawn</code></a> spawns a prefab chosen at runtime by name.</p>
<div class="ns-methods"><a class="ns-method" href="prefab-spawn.html"><code class="nm-sig">Prefab.spawn(name: s) -&gt; entity</code><span class="nm-tip">Spawn a prefab chosen by name at runtime; -1 if none has that name.</span></a><a class="ns-method" href="prefab-spawn_at.html"><code class="nm-sig">Prefab.spawn_at(name: s, at: IVec2) -&gt; entity</code><span class="nm-tip">Spawn a prefab by name and place it.</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>