diff --git a/docs/language/annotations/_section.md b/docs/language/annotations/_section.md index 5da3cb23..dd7730c0 100644 --- a/docs/language/annotations/_section.md +++ b/docs/language/annotations/_section.md @@ -1,7 +1,7 @@ --- id: annotations title: Annotations -order: 13 +order: 14 --- @Name(...) decorators attach compile-time behavior to a handler, property, or function. diff --git a/docs/language/builtins/_section.md b/docs/language/builtins/_section.md index d26212f5..3d28d8f5 100644 --- a/docs/language/builtins/_section.md +++ b/docs/language/builtins/_section.md @@ -1,7 +1,7 @@ --- id: builtins title: Builtin functions -order: 12 +order: 13 --- Global functions available anywhere, beyond the namespaced APIs above. diff --git a/docs/language/builtins/fn-arg.md b/docs/language/builtins/fn-arg.md new file mode 100644 index 00000000..a4ab5252 --- /dev/null +++ b/docs/language/builtins/fn-arg.md @@ -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: arg_count() is the number of arguments (including the program name at index 0) and arg(i) returns the ith as a string. diff --git a/docs/language/builtins/fn-exit.md b/docs/language/builtins/fn-exit.md new file mode 100644 index 00000000..e69f486b --- /dev/null +++ b/docs/language/builtins/fn-exit.md @@ -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 quit(), which ends the game loop cleanly after the current frame, exit stops the program at once. diff --git a/docs/language/builtins/fn-file.md b/docs/language/builtins/fn-file.md new file mode 100644 index 00000000..603545cd --- /dev/null +++ b/docs/language/builtins/fn-file.md @@ -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 +--- + +file_stdout() and file_stderr() return the standard stream handles; file_write(handle, buf, len) writes len raw bytes to one. Most code uses print instead — these are the primitive underneath. diff --git a/docs/language/builtins/fn-getenv.md b/docs/language/builtins/fn-getenv.md new file mode 100644 index 00000000..68ee16af --- /dev/null +++ b/docs/language/builtins/fn-getenv.md @@ -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 name (empty when it is unset). diff --git a/docs/language/builtins/fn-read_char.md b/docs/language/builtins/fn-read_char.md new file mode 100644 index 00000000..beabf9af --- /dev/null +++ b/docs/language/builtins/fn-read_char.md @@ -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 -1 at end of input — the basis for headless, pipe-driven runs. diff --git a/docs/language/builtins/fn-run.md b/docs/language/builtins/fn-run.md new file mode 100644 index 00000000..08b8db42 --- /dev/null +++ b/docs/language/builtins/fn-run.md @@ -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 cmd as a shell command — handy for build steps and tooling written in Ludic. diff --git a/docs/language/colors/_section.md b/docs/language/colors/_section.md index e7937c23..f0665134 100644 --- a/docs/language/colors/_section.md +++ b/docs/language/colors/_section.md @@ -1,7 +1,7 @@ --- id: colors title: Color — the named palette -order: 9 +order: 10 --- Color.Name lowers to a plain 0xRRGGBB 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 const. The full palette: diff --git a/docs/language/networking/_section.md b/docs/language/networking/_section.md new file mode 100644 index 00000000..c04e5a6f --- /dev/null +++ b/docs/language/networking/_section.md @@ -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 @Sync and models @Owned; the compiler generates the replication. These are the low-level primitives beneath that sugar, for when you drive the transport yourself. diff --git a/docs/language/networking/fn-is_server.md b/docs/language/networking/fn-is_server.md new file mode 100644 index 00000000..a2a7f924 --- /dev/null +++ b/docs/language/networking/fn-is_server.md @@ -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. is_server() is the authority check, is_owner(e) is true when this peer owns e, and local_id() is this peer's id. Prefer role annotations to sprinkling these through gameplay code. diff --git a/docs/language/networking/fn-net_poll.md b/docs/language/networking/fn-net_poll.md new file mode 100644 index 00000000..32e9521e --- /dev/null +++ b/docs/language/networking/fn-net_poll.md @@ -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 cap waiting bytes into buf and return how many arrived (0 when nothing is queued). Pair it with the generated apply to fold an update back into the world. diff --git a/docs/language/networking/fn-net_send.md b/docs/language/networking/fn-net_send.md new file mode 100644 index 00000000..87b95771 --- /dev/null +++ b/docs/language/networking/fn-net_send.md @@ -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 len bytes from buf to peer. 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. diff --git a/docs/language/networking/fn-owner.md b/docs/language/networking/fn-owner.md new file mode 100644 index 00000000..0cc0a801 --- /dev/null +++ b/docs/language/networking/fn-owner.md @@ -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 +--- + +@Owned gives a model an owner slot; owner(e) reads the peer id that owns entity e and set_owner(e, id) assigns it (the authority decides). Ownership gates who may write @Sync(to: owner) fields. diff --git a/docs/language/networking/fn-serialize.md b/docs/language/networking/fn-serialize.md new file mode 100644 index 00000000..a5974867 --- /dev/null +++ b/docs/language/networking/fn-serialize.md @@ -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: serialize writes an entity's @Sync fields into buf and returns the length; apply folds received bytes back onto an entity. Together they are the replication substrate the sugar builds on. diff --git a/docs/language/operators/_section.md b/docs/language/operators/_section.md index 971a7c33..dc70d54b 100644 --- a/docs/language/operators/_section.md +++ b/docs/language/operators/_section.md @@ -1,7 +1,7 @@ --- id: operators title: Operators & tokens -order: 11 +order: 12 --- The symbols the grammar recognizes. diff --git a/docs/language/types/_section.md b/docs/language/types/_section.md index 05af7757..8ae36b12 100644 --- a/docs/language/types/_section.md +++ b/docs/language/types/_section.md @@ -1,7 +1,7 @@ --- id: types title: Types -order: 10 +order: 11 --- Ludic is statically typed; most code uses just int.