39 lines
No EOL
2.4 KiB
HTML
39 lines
No EOL
2.4 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>@OnQuit — Ludic</title>
|
||
<meta name="description" content="Run a handler once at shutdown, after the last frame.">
|
||
<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#annotations">Annotations</a> <span>›</span> <span class="here">@OnQuit</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-annotation">annotation</span>
|
||
<h1 id="top">@OnQuit</h1>
|
||
</div>
|
||
<code class="sig">@OnQuit handler Name { … }</code>
|
||
<div class="desc"><p><code>@OnQuit</code> pins a handler to the program's shutdown moment: it runs exactly once as the program exits, after the final frame. Use it for teardown that must happen once — flushing a save, printing a final tally, releasing a host resource. In the lifecycle timeline it runs after every still-live instance's <code>@OnDespawn</code> hook has fired, so the world has already been torn down by the time <code>@OnQuit</code> sees it. It is the boot-time counterpart of <code>@OnStart</code>; add <code>@Public</code> to also emit a <code>program_quit</code> event other modules can hook.</p></div>
|
||
|
||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program QuitHook {
|
||
property Score { total: int = 0 }
|
||
model Scoreboard { Score }
|
||
|
||
@OnQuit handler ReportFinalScore { # runs once at shutdown
|
||
for (Score) in query [Score] { print(Score.total) }
|
||
}
|
||
|
||
handler Seed phase Start { spawn Scoreboard { Score { total: 42 } } }
|
||
|
||
handler Finish phase Render { quit() } # triggers shutdown -> prints 42
|
||
}</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> |