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

44 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>world_size — Ludic</title>
<meta name="description" content="The number of live model instances in the world.">
<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#ecs">Entities &amp; the ECS</a> <span>›</span> <span class="here">world_size</span></div>
<div class="item-head">
<span class="kind-badge kind-builtin">function</span>
<h1 id="top">world_size</h1>
</div>
<code class="sig">world_size() -&gt; int</code>
<div class="desc"><p><code>world_size</code> returns the total number of live model instances in the world, across every kind, as an <code>int</code>. It takes no arguments and is the cheapest way to answer "how big is the world right now?" — useful for a debug readout, a capacity check before a big spawn, or a mod inspecting the running game through the reflection ABI. For a count restricted to instances carrying a particular property, use <code>world_count</code> instead.</p></div>
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program WorldSize {
property Position { column: int = 0, row: int = 0 }
model Enemy { Position }
handler Boot phase Start {
spawn GruntA { Position { column: 4, row: 4 } }
spawn GruntB { Position { column: 6, row: 4 } }
spawn GruntC { Position { column: 8, row: 4 } }
}
handler DrawWorld phase Render {
Screen.clear(Color.MidnightBlue)
let total = world_size()
Screen.draw_number(x: 8, y: 8, value: total, color: Color.White, scale: 2)
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>