37 lines
No EOL
2.7 KiB
HTML
37 lines
No EOL
2.7 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>import — Ludic</title>
|
||
<meta name="description" content="Splice another Ludic file's declarations into this program.">
|
||
<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">import</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-keyword">keyword</span>
|
||
<h1 id="top">import</h1>
|
||
</div>
|
||
<code class="sig">import "file.ludic"</code>
|
||
<div class="desc"><p>An <code>import</code> pulls the declarations of another Ludic file into this program, letting you split a game across many files instead of one giant block. The imported file is a <b>fragment</b> — bare declarations with no <code>program</code> wrapper — and its contents are spliced in as if written here. Paths resolve relative to the importing file, imports may nest, and each resolved path is include-guarded, so importing the same file twice (even through different chains) pulls it in exactly once. Diagnostics still point at the real source file, so errors in an imported fragment report that file's name and line.</p><p>A path without <code>.ludic</code> names a directory through its barrel, <code>index.ludic</code>: <code>import "camp"</code> reads <code>camp/index.ludic</code>, which lists the directory's modules with imports relative to itself. <code>import "dir/*.ludic"</code> instead takes every file in the directory, in name order.</p></div>
|
||
|
||
<div class="examples"><h2>Example</h2><pre data-lang="ludic"># doc-check: skip — illustrative; the imported paths are example files, not
|
||
# resolvable when this snippet is checked in isolation.
|
||
program ChronoRift {
|
||
import "chronorift/world.ludic" # properties and models
|
||
import "chronorift/combat.ludic" # the battle handlers
|
||
|
||
handler Boot phase Start {
|
||
spawn Hero { Position { column: 4, row: 4 } }
|
||
}
|
||
}</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> |