ludic/kw-public.html
2026-09-17 22:10:03 +00:00

35 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>public — Ludic</title>
<meta name="description" content="Expose a declaration&#x27;s lifecycle on the public event bus.">
<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> <a href="api.html#structure">Program structure</a> <span>›</span> <span class="here">public</span></div>
<div class="item-head">
<span class="kind-badge kind-keyword">keyword</span>
<h1 id="top">public</h1>
</div>
<code class="sig">scene Name start public { … }</code>
<div class="desc"><p><code>public</code> marks a <code>scene</code>, <code>layer</code>, or <code>event</code> as part of the game's public surface, so its lifecycle is emitted as named events other systems and mods can react to with <code>@On</code>. A <code>public</code> scene fires <code>scene_&lt;Name&gt;_enter</code> and <code>scene_&lt;Name&gt;_exit</code>; a <code>public</code> layer fires <code>layer_&lt;Name&gt;_show</code> / <code>_hide</code>. It is the declaration-level counterpart to the <code>@Public</code> annotation that promotes a model or handler's lifecycle hooks. Keep it off by default and add it only where the modding surface genuinely needs the hook.</p></div>
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Flow {
@On(scene_Menu_enter) handler Greet { print(1) }
scene Menu start public {
on enter { print(10) } # entering Menu prints 10, then fires scene_Menu_enter
on exit { print(20) }
}
}</pre></div>
<a class="back" href="api.html">← All symbols</a>
</main>
<script src="ludic-highlight.js"></script>
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
</body></html>