docs: regenerate site from f094acfdb5

This commit is contained in:
ludic-docs-bot 2026-09-17 22:10:03 +00:00
commit 63c5ed9baf
975 changed files with 55427 additions and 0 deletions

47
kw-state.html Normal file
View file

@ -0,0 +1,47 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>state — Ludic</title>
<meta name="description" content="One state of a machine — its body runs while the machine sits in it.">
<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#control">Control flow</a> <span>›</span> <span class="here">state</span></div>
<div class="item-head">
<span class="kind-badge kind-keyword">keyword</span>
<h1 id="top">state</h1>
</div>
<code class="sig">state Name { … }</code>
<div class="desc"><p>A <code>state</code> declares one state of an enclosing <code>machine</code>: a named block whose body runs while the machine's store holds that state's value. States take their value from declaration order — the first <code>state</code> is <code>0</code>, the next <code>1</code>, and so on — so you refer to them by name and never track the numbers yourself (write <code>state Name = expr</code> only when a state must have a specific value). From inside a state, <code>become OtherName</code> transitions the machine by storing the target state's value back into the store. Keep each state focused on the logic for that mode and hand off with <code>become</code> when its condition to move on is met.</p></div>
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program DoorControl {
enum DoorState { Closed, Opening, Open }
var door: int = DoorState.Closed
var elapsed_frames: int = 0
handler RunDoor phase Update {
machine door {
state Closed {
if Input.key() == ' ' { elapsed_frames = 0; become Opening }
}
state Opening {
elapsed_frames = elapsed_frames + 1
if elapsed_frames &gt;= 30 { become Open }
}
state Open {
Screen.status("door open")
}
}
}
}</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>