28 lines
No EOL
5.9 KiB
HTML
28 lines
No EOL
5.9 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Os — Ludic</title>
|
||
<meta name="description" content="The operating-system interface — the environment *around* the game rather than the game itself: the command line, environment variables, the standard streams,…">
|
||
<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> <span class="here">Os</span></div>
|
||
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Os</h1></div>
|
||
<p class="ns-blurb">The operating-system interface — the environment *around* the game rather than the game itself: the command line, environment variables, the standard streams, the process exit code, the host platform, and the per-user folders a game writes its saves, config, and cache into. It rounds the bare <a href="ns-System"><code>System</code></a> builtins (<code>arg</code>, <code>getenv</code>, <code>exit</code>) into one coherent, Go-flavored namespace.
|
||
|
||
It is deliberately small and game-scoped: there is no process spawning, no signals, and no user/permission APIs. Reach for it in launchers, asset pipelines, and dev tools — parsing launch flags like <code>--level 3</code>, reading config from the environment, or resolving where a save file belongs — far more than in the simulation itself.
|
||
|
||
**Determinism:** <a href="os-args"><code>args</code></a>, the <a href="os-env"><code>env</code></a> family, and <a href="os-platform"><code>platform</code></a>/<a href="os-arch"><code>arch</code></a> are non-deterministic host input. Read them once at startup to configure the game, and keep them out of the replayable simulation so a shared seed still reproduces.
|
||
|
||
**Platform coverage:** this first version targets the native macOS/BSD host — the fully supported target today. <a href="os-platform"><code>platform</code></a> is portable (the <code>uname</code> system name is available on every Unix); <a href="os-arch"><code>arch</code></a> and the known-folder layout (<a href="os-save_dir"><code>save_dir</code></a>/<a href="os-config_dir"><code>config_dir</code></a>/<a href="os-cache_dir"><code>cache_dir</code></a>) follow the macOS conventions. Linux/Windows/wasm folder resolution and a target-aware <code>arch</code> are documented follow-ups.</p>
|
||
<div class="ns-methods"><a class="ns-method" href="os-args.html"><code class="nm-sig">Os.args() -> []string</code><span class="nm-tip">Every command-line argument, as a list.</span></a><a class="ns-method" href="os-arg_count.html"><code class="nm-sig">Os.arg_count() -> int</code><span class="nm-tip">How many command-line arguments there are.</span></a><a class="ns-method" href="os-arg.html"><code class="nm-sig">Os.arg(i) -> string</code><span class="nm-tip">The i-th command-line argument.</span></a><a class="ns-method" href="os-env.html"><code class="nm-sig">Os.env(name) -> string</code><span class="nm-tip">Read an environment variable (null if unset).</span></a><a class="ns-method" href="os-env_or.html"><code class="nm-sig">Os.env_or(name, fallback) -> string</code><span class="nm-tip">Read an environment variable, or a fallback.</span></a><a class="ns-method" href="os-has_env.html"><code class="nm-sig">Os.has_env(name) -> bool</code><span class="nm-tip">Is an environment variable set?</span></a><a class="ns-method" href="os-set_env.html"><code class="nm-sig">Os.set_env(name, value) -> bool</code><span class="nm-tip">Set an environment variable.</span></a><a class="ns-method" href="os-unset_env.html"><code class="nm-sig">Os.unset_env(name) -> bool</code><span class="nm-tip">Remove an environment variable.</span></a><a class="ns-method" href="os-exit.html"><code class="nm-sig">Os.exit(code)</code><span class="nm-tip">Terminate the process with a status code.</span></a><a class="ns-method" href="os-platform.html"><code class="nm-sig">Os.platform() -> string</code><span class="nm-tip">The host platform id.</span></a><a class="ns-method" href="os-arch.html"><code class="nm-sig">Os.arch() -> string</code><span class="nm-tip">The host CPU architecture.</span></a><a class="ns-method" href="os-stdout_write.html"><code class="nm-sig">Os.stdout_write(s)</code><span class="nm-tip">Write a string to standard output.</span></a><a class="ns-method" href="os-stderr_write.html"><code class="nm-sig">Os.stderr_write(s)</code><span class="nm-tip">Write a string to standard error.</span></a><a class="ns-method" href="os-save_dir.html"><code class="nm-sig">Os.save_dir(app) -> string</code><span class="nm-tip">Per-user save directory for an app.</span></a><a class="ns-method" href="os-config_dir.html"><code class="nm-sig">Os.config_dir(app) -> string</code><span class="nm-tip">Per-user config directory for an app.</span></a><a class="ns-method" href="os-cache_dir.html"><code class="nm-sig">Os.cache_dir(app) -> string</code><span class="nm-tip">Per-user cache directory for an app.</span></a><a class="ns-method" href="os-temp_dir.html"><code class="nm-sig">Os.temp_dir() -> string</code><span class="nm-tip">The system temporary directory.</span></a><a class="ns-method" href="os-pid.html"><code class="nm-sig">Os.pid() -> int</code><span class="nm-tip">This process's id.</span></a></div>
|
||
<a class="back" href="api.html">← All symbols</a>
|
||
</main>
|
||
<script src="ludic-highlight.js"></script>
|
||
<script>Ludic.installCards(); Ludic.flashTarget();</script>
|
||
</body></html> |