docs: add Networking section + process/OS builtins (net_send, owner, is_server, serialize/apply, arg, exit, run, getenv, read_char, file_*)
All checks were successful
docs / build-and-deploy (push) Successful in 1s
All checks were successful
docs / build-and-deploy (push) Successful in 1s
Sourced from the compiler's confirmed builtin set and NETWORKING-DESIGN.md, so the reference reflects the current language surface. 93 -> 104 symbols. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ccef707e4c
commit
25f987e30d
17 changed files with 144 additions and 5 deletions
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
id: annotations
|
||||
title: Annotations
|
||||
order: 13
|
||||
order: 14
|
||||
---
|
||||
|
||||
<code>@Name(...)</code> decorators attach compile-time behavior to a handler, property, or function.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
id: builtins
|
||||
title: Builtin functions
|
||||
order: 12
|
||||
order: 13
|
||||
---
|
||||
|
||||
Global functions available anywhere, beyond the namespaced APIs above.
|
||||
|
|
|
|||
12
docs/language/builtins/fn-arg.md
Normal file
12
docs/language/builtins/fn-arg.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
id: fn-arg
|
||||
name: arg_count / arg
|
||||
category: builtins
|
||||
kind: builtin
|
||||
tokens: arg_count arg
|
||||
sig: arg_count() -> int arg(i) -> str
|
||||
tip: The command line; argv[0] is included.
|
||||
order: 20
|
||||
---
|
||||
|
||||
Read the process command line: <code>arg_count()</code> is the number of arguments (including the program name at index 0) and <code>arg(i)</code> returns the <code>i</code>th as a string.
|
||||
12
docs/language/builtins/fn-exit.md
Normal file
12
docs/language/builtins/fn-exit.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
id: fn-exit
|
||||
name: exit
|
||||
category: builtins
|
||||
kind: builtin
|
||||
tokens: exit
|
||||
sig: exit(code)
|
||||
tip: Exit the process immediately with a status code.
|
||||
order: 21
|
||||
---
|
||||
|
||||
Terminate the process now with the given status code. Unlike <code>quit()</code>, which ends the game loop cleanly after the current frame, <code>exit</code> stops the program at once.
|
||||
12
docs/language/builtins/fn-file.md
Normal file
12
docs/language/builtins/fn-file.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
id: fn-file
|
||||
name: file_write / file_stdout / file_stderr
|
||||
category: builtins
|
||||
kind: builtin
|
||||
tokens: file_write file_stdout file_stderr
|
||||
sig: file_stdout() -> ptr file_stderr() -> ptr file_write(handle, buf, len)
|
||||
tip: Low-level output handles and raw writing.
|
||||
order: 25
|
||||
---
|
||||
|
||||
<code>file_stdout()</code> and <code>file_stderr()</code> return the standard stream handles; <code>file_write(handle, buf, len)</code> writes <code>len</code> raw bytes to one. Most code uses <code>print</code> instead — these are the primitive underneath.
|
||||
12
docs/language/builtins/fn-getenv.md
Normal file
12
docs/language/builtins/fn-getenv.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
id: fn-getenv
|
||||
name: getenv
|
||||
category: builtins
|
||||
kind: builtin
|
||||
tokens: getenv
|
||||
sig: getenv(name) -> str
|
||||
tip: Read an environment variable.
|
||||
order: 23
|
||||
---
|
||||
|
||||
Return the value of environment variable <code>name</code> (empty when it is unset).
|
||||
12
docs/language/builtins/fn-read_char.md
Normal file
12
docs/language/builtins/fn-read_char.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
id: fn-read_char
|
||||
name: read_char
|
||||
category: builtins
|
||||
kind: builtin
|
||||
tokens: read_char
|
||||
sig: read_char() -> int
|
||||
tip: Read one byte from standard input (-1 at end of input).
|
||||
order: 24
|
||||
---
|
||||
|
||||
Read a single byte from standard input, returning its value or <code>-1</code> at end of input — the basis for headless, pipe-driven runs.
|
||||
12
docs/language/builtins/fn-run.md
Normal file
12
docs/language/builtins/fn-run.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
id: fn-run
|
||||
name: run
|
||||
category: builtins
|
||||
kind: builtin
|
||||
tokens: run
|
||||
sig: run(cmd)
|
||||
tip: Run a shell command.
|
||||
order: 22
|
||||
---
|
||||
|
||||
Run <code>cmd</code> as a shell command — handy for build steps and tooling written in Ludic.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
id: colors
|
||||
title: Color — the named palette
|
||||
order: 9
|
||||
order: 10
|
||||
---
|
||||
|
||||
<code>Color.Name</code> lowers to a plain <code>0xRRGGBB</code> integer at compile time — no runtime cost, identical to writing the hex by hand, but readable. 221 names are built in; a custom shade is any hex literal or a named <code>const</code>. The full palette:
|
||||
|
|
|
|||
7
docs/language/networking/_section.md
Normal file
7
docs/language/networking/_section.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
id: networking
|
||||
title: Networking
|
||||
order: 9
|
||||
---
|
||||
|
||||
Multiplayer is a compile-time property of the ECS, not glue you thread by hand. Mark fields <code>@Sync</code> and models <code>@Owned</code>; the compiler generates the replication. These are the low-level primitives beneath that sugar, for when you drive the transport yourself.
|
||||
12
docs/language/networking/fn-is_server.md
Normal file
12
docs/language/networking/fn-is_server.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
id: fn-is_server
|
||||
name: is_server / is_owner / local_id
|
||||
category: networking
|
||||
kind: builtin
|
||||
tokens: is_server is_owner local_id
|
||||
sig: is_server() -> bool is_owner(e) -> bool local_id() -> int
|
||||
tip: Role and identity checks the runtime sets.
|
||||
order: 3
|
||||
---
|
||||
|
||||
The runtime sets the local role. <code>is_server()</code> is the authority check, <code>is_owner(e)</code> is true when this peer owns <code>e</code>, and <code>local_id()</code> is this peer's id. Prefer role annotations to sprinkling these through gameplay code.
|
||||
12
docs/language/networking/fn-net_poll.md
Normal file
12
docs/language/networking/fn-net_poll.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
id: fn-net_poll
|
||||
name: net_poll
|
||||
category: networking
|
||||
kind: builtin
|
||||
tokens: net_poll
|
||||
sig: net_poll(buf, cap) -> int
|
||||
tip: Receive queued bytes from the transport; returns the byte count.
|
||||
order: 1
|
||||
---
|
||||
|
||||
Copy up to <code>cap</code> waiting bytes into <code>buf</code> and return how many arrived (0 when nothing is queued). Pair it with the generated <code>apply</code> to fold an update back into the world.
|
||||
12
docs/language/networking/fn-net_send.md
Normal file
12
docs/language/networking/fn-net_send.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
id: fn-net_send
|
||||
name: net_send
|
||||
category: networking
|
||||
kind: builtin
|
||||
tokens: net_send
|
||||
sig: net_send(peer, buf, len)
|
||||
tip: Send bytes to a peer over the host's transport.
|
||||
order: 0
|
||||
---
|
||||
|
||||
Send <code>len</code> bytes from <code>buf</code> to <code>peer</code>. The transport itself is a host-provided seam — UDP natively, WebRTC/WebSocket on the web, or a loopback in tests — so the same game runs over any of them.
|
||||
12
docs/language/networking/fn-owner.md
Normal file
12
docs/language/networking/fn-owner.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
id: fn-owner
|
||||
name: owner / set_owner
|
||||
category: networking
|
||||
kind: builtin
|
||||
tokens: owner set_owner
|
||||
sig: owner(e) -> int set_owner(e, id)
|
||||
tip: Read or assign an entity's network owner.
|
||||
order: 2
|
||||
---
|
||||
|
||||
<code>@Owned</code> gives a model an owner slot; <code>owner(e)</code> reads the peer id that owns entity <code>e</code> and <code>set_owner(e, id)</code> assigns it (the authority decides). Ownership gates who may write <code>@Sync(to: owner)</code> fields.
|
||||
12
docs/language/networking/fn-serialize.md
Normal file
12
docs/language/networking/fn-serialize.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
id: fn-serialize
|
||||
name: serialize / apply
|
||||
category: networking
|
||||
kind: builtin
|
||||
tokens: serialize apply
|
||||
sig: serialize(e, buf) -> int apply(e, buf, len)
|
||||
tip: Compiler-generated per-model replication of @Sync fields.
|
||||
order: 4
|
||||
---
|
||||
|
||||
Generated from the ECS schema per model: <code>serialize</code> writes an entity's <code>@Sync</code> fields into <code>buf</code> and returns the length; <code>apply</code> folds received bytes back onto an entity. Together they are the replication substrate the sugar builds on.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
id: operators
|
||||
title: Operators & tokens
|
||||
order: 11
|
||||
order: 12
|
||||
---
|
||||
|
||||
The symbols the grammar recognizes.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
id: types
|
||||
title: Types
|
||||
order: 10
|
||||
order: 11
|
||||
---
|
||||
|
||||
Ludic is statically typed; most code uses just <code>int</code>.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue