ludic/fn-save.html
2026-09-17 22:10:03 +00:00

46 lines
No EOL
2.3 KiB
HTML
Raw 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>save — Ludic</title>
<meta name="description" content="Serialize the whole world — every model instance, property, and program var — in one call.">
<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#builtins">Builtin functions</a> <span>›</span> <span class="here">save</span></div>
<div class="item-head">
<span class="kind-badge kind-builtin">function</span>
<h1 id="top">save</h1>
</div>
<code class="sig">save()</code>
<div class="desc"><p>Captures a complete snapshot of the running world in a single call: every spawned model instance and its properties, plus every program-level <code>var</code>. The compiler generates the serialization for you from your declarations, so you never write it by hand. Pair it with <code>load</code> to implement quick-save / quick-load, checkpoints, or deterministic test fixtures. It takes no arguments and writes to the runtime's snapshot slot; calling it again overwrites the previous snapshot.</p></div>
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program QuickSave {
property Position { column: int = 0, row: int = 0 }
model Player { Position }
handler SpawnPlayer phase Start {
spawn Player { Position { column: 5, row: 5 } }
}
handler ReadInput phase Input {
let pressed = Input.key()
if pressed == 's' { save() }
if pressed == 'l' { load() }
}
handler DrawWorld phase Render {
Screen.clear(Color.MidnightBlue)
Screen.show()
}
}</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>