Coldwave Read the docs

Protocol: net, part 2 of 2#

The net commands a program sends to a running game, as the engine describes them: what each takes, what it answers and what it does. Back to all commands.

net.condition#

net.condition {latency_ms?: integer, jitter_ms?: integer, loss?: number, seed?: integer, cut_after_ms?: integer, cut_for_ms?: integer} -> {player: integer, players: integer, host: value, address: text, started: value, played: integer, confirmed: integer, delay: integer, window: integer, sync_every: integer, counters: record, link: record, peers: [record], desync: record, token: integer, open: [record], join: record, words: text, sums: [text]} · write

For tests: makes what this peer sends from now on worse, by a seeded choice so a test is the same every run: each datagram held back latency_ms, give or take jitter_ms, or dropped with the chance loss.

ParametersTypeMeaning
latency_ms?integerMilliseconds each datagram is held back. Left out: 0.
jitter_ms?integerMilliseconds more or less, at random. Left out: 0.
loss?numberThe chance a datagram is dropped, 0 to 1. Left out: 0.
seed?integerThe seed of the choices. Left out: 1.
cut_after_ms?integerWith cut_for_ms: nothing at all is sent for cut_for_ms from this many milliseconds after now, as a cut cable; what comes in still comes.
cut_for_ms?integerHow long the cut lasts.
ResultTypeMeaning
playerintegerThe player this peer owns: its peer number. The host is 0.
playersintegerHow many players the game has: [input] players.
hostvalueWhether this peer opened the session.
addresstextWhere this peer's socket is, 127.0.0.1:PORT.
startedvalueWhether the game has begun: every player is in and a net.run has played.
playedintegerThe steps played: the step the game stands at, some of it predicted.
confirmedintegerThe newest step every player's real input is in for: never played again, its checksum final.
delayintegerSteps between a local input and the step it is for.
windowintegerThe most steps played ahead of the confirmed one.
sync_everyintegerSteps between two exchanges of the world's checksum.
countersrecord{steps, rollbacks, replayed, deepest, wrong, stalls, late_sounds, stray_sounds, slowest_us}: steps played for the first time; times the game was put back; steps played again; the most one rollback played again; real inputs that differed from what was predicted; times the next step waited for the window; sounds a correction asked for, played late; sounds only a wrong prediction asked for, let finish; the slowest frame of rollback in microseconds.
linkrecord{sent, dropped, received, latency_ms, jitter_ms, loss}: datagrams sent, dropped on purpose by net.condition, received, and the condition.
peers[record]One {player, address, acked, heard_ms, left} per other peer: the newest step of this peer's player it holds every input up to, and how long since it was heard.
desyncrecordnull while every checksum exchanged agreed. Else {code, step, player, here, there, part, thing, value_here, value_there, written_here, written_there}: code is E0542; the first confirmed step whose checksum differed from the peer's, both checksums, the first part of the world that differs (as world.checksum names parts: "Transform.x", "state:main.luau:score", "entities", "random"), and for a field the first thing whose value differs with both values, and who last wrote it on each side as blame.value's writer says it ({kind: "script", file, line, function} for a script's line, a system, or a client), found by playing the game again from the last moment both agreed on with blame on.
tokenintegerThis peer's seat's token, given by the host: what it shows (net.join's token) to come back to its seat after it was dropped or left. It is sent in clear: it keeps a seat from a stranger who asks by mistake, not from one who reads the datagrams.
open[record]One {player, from} per seat the game began without (net.run's begin_with): from is the step a late joiner's own input counts from, null while the seat is open. The host plays an open seat at rest.
joinrecordnull, or what a late join measured on this end: {player, step, bytes, chunks, resent, asked, from, ms, gave_up}: the seat, the moment's step and size in bytes and in chunks of 1,183 bytes, the chunks the host sent again and the joiner asked for again, the step the joiner's own input counts from, the milliseconds from its asking to being given that step (the joiner's), and whether the host gave up on a joiner gone silent.
wordstextWhat a window says about the session now, the line its title shows: players to wait for, a peer silent and for how long, one that left, worlds that differ. null when there is nothing to say.
sums[text]With sums: true, the checksum after every confirmed step since the game began, 16 hex digits each; else empty.

net.status#

net.status {sums?: value} -> {player: integer, players: integer, host: value, address: text, started: value, played: integer, confirmed: integer, delay: integer, window: integer, sync_every: integer, counters: record, link: record, peers: [record], desync: record, token: integer, open: [record], join: record, words: text, sums: [text]} · read, read-only

Reads the session: the peers, the steps played and confirmed, the rollback's counters, the link's, and the first difference found between two worlds. E0544 with no session.

ParametersTypeMeaning
sums?valuetrue: the checksum of every confirmed step too.
ResultTypeMeaning
playerintegerThe player this peer owns: its peer number. The host is 0.
playersintegerHow many players the game has: [input] players.
hostvalueWhether this peer opened the session.
addresstextWhere this peer's socket is, 127.0.0.1:PORT.
startedvalueWhether the game has begun: every player is in and a net.run has played.
playedintegerThe steps played: the step the game stands at, some of it predicted.
confirmedintegerThe newest step every player's real input is in for: never played again, its checksum final.
delayintegerSteps between a local input and the step it is for.
windowintegerThe most steps played ahead of the confirmed one.
sync_everyintegerSteps between two exchanges of the world's checksum.
countersrecord{steps, rollbacks, replayed, deepest, wrong, stalls, late_sounds, stray_sounds, slowest_us}: steps played for the first time; times the game was put back; steps played again; the most one rollback played again; real inputs that differed from what was predicted; times the next step waited for the window; sounds a correction asked for, played late; sounds only a wrong prediction asked for, let finish; the slowest frame of rollback in microseconds.
linkrecord{sent, dropped, received, latency_ms, jitter_ms, loss}: datagrams sent, dropped on purpose by net.condition, received, and the condition.
peers[record]One {player, address, acked, heard_ms, left} per other peer: the newest step of this peer's player it holds every input up to, and how long since it was heard.
desyncrecordnull while every checksum exchanged agreed. Else {code, step, player, here, there, part, thing, value_here, value_there, written_here, written_there}: code is E0542; the first confirmed step whose checksum differed from the peer's, both checksums, the first part of the world that differs (as world.checksum names parts: "Transform.x", "state:main.luau:score", "entities", "random"), and for a field the first thing whose value differs with both values, and who last wrote it on each side as blame.value's writer says it ({kind: "script", file, line, function} for a script's line, a system, or a client), found by playing the game again from the last moment both agreed on with blame on.
tokenintegerThis peer's seat's token, given by the host: what it shows (net.join's token) to come back to its seat after it was dropped or left. It is sent in clear: it keeps a seat from a stranger who asks by mistake, not from one who reads the datagrams.
open[record]One {player, from} per seat the game began without (net.run's begin_with): from is the step a late joiner's own input counts from, null while the seat is open. The host plays an open seat at rest.
joinrecordnull, or what a late join measured on this end: {player, step, bytes, chunks, resent, asked, from, ms, gave_up}: the seat, the moment's step and size in bytes and in chunks of 1,183 bytes, the chunks the host sent again and the joiner asked for again, the step the joiner's own input counts from, the milliseconds from its asking to being given that step (the joiner's), and whether the host gave up on a joiner gone silent.
wordstextWhat a window says about the session now, the line its title shows: players to wait for, a peer silent and for how long, one that left, worlds that differ. null when there is nothing to say.
sums[text]With sums: true, the checksum after every confirmed step since the game began, 16 hex digits each; else empty.

net.desync#

net.desync {step: integer, entity?: text, component?: text, field?: text} -> {player: integer, players: integer, host: value, address: text, started: value, played: integer, confirmed: integer, delay: integer, window: integer, sync_every: integer, counters: record, link: record, peers: [record], desync: record, token: integer, open: [record], join: record, words: text, sums: [text]} · write

For tests: changes this peer's world after a step, every time that step is played, as a game that is not deterministic would (the field named grows by one; left out, the first thing with a Transform moves one unit along x, and the random source is drawn from where there is none), written as a client's write, so the peers find the worlds differ and name it.

ParametersTypeMeaning
stepintegerThe step after which it is changed.
entity?textThe thing whose field is changed by one, with component and field. Left out: the first thing with a Transform, along x.
component?textIts component.
field?textIts field: a number.
ResultTypeMeaning
playerintegerThe player this peer owns: its peer number. The host is 0.
playersintegerHow many players the game has: [input] players.
hostvalueWhether this peer opened the session.
addresstextWhere this peer's socket is, 127.0.0.1:PORT.
startedvalueWhether the game has begun: every player is in and a net.run has played.
playedintegerThe steps played: the step the game stands at, some of it predicted.
confirmedintegerThe newest step every player's real input is in for: never played again, its checksum final.
delayintegerSteps between a local input and the step it is for.
windowintegerThe most steps played ahead of the confirmed one.
sync_everyintegerSteps between two exchanges of the world's checksum.
countersrecord{steps, rollbacks, replayed, deepest, wrong, stalls, late_sounds, stray_sounds, slowest_us}: steps played for the first time; times the game was put back; steps played again; the most one rollback played again; real inputs that differed from what was predicted; times the next step waited for the window; sounds a correction asked for, played late; sounds only a wrong prediction asked for, let finish; the slowest frame of rollback in microseconds.
linkrecord{sent, dropped, received, latency_ms, jitter_ms, loss}: datagrams sent, dropped on purpose by net.condition, received, and the condition.
peers[record]One {player, address, acked, heard_ms, left} per other peer: the newest step of this peer's player it holds every input up to, and how long since it was heard.
desyncrecordnull while every checksum exchanged agreed. Else {code, step, player, here, there, part, thing, value_here, value_there, written_here, written_there}: code is E0542; the first confirmed step whose checksum differed from the peer's, both checksums, the first part of the world that differs (as world.checksum names parts: "Transform.x", "state:main.luau:score", "entities", "random"), and for a field the first thing whose value differs with both values, and who last wrote it on each side as blame.value's writer says it ({kind: "script", file, line, function} for a script's line, a system, or a client), found by playing the game again from the last moment both agreed on with blame on.
tokenintegerThis peer's seat's token, given by the host: what it shows (net.join's token) to come back to its seat after it was dropped or left. It is sent in clear: it keeps a seat from a stranger who asks by mistake, not from one who reads the datagrams.
open[record]One {player, from} per seat the game began without (net.run's begin_with): from is the step a late joiner's own input counts from, null while the seat is open. The host plays an open seat at rest.
joinrecordnull, or what a late join measured on this end: {player, step, bytes, chunks, resent, asked, from, ms, gave_up}: the seat, the moment's step and size in bytes and in chunks of 1,183 bytes, the chunks the host sent again and the joiner asked for again, the step the joiner's own input counts from, the milliseconds from its asking to being given that step (the joiner's), and whether the host gave up on a joiner gone silent.
wordstextWhat a window says about the session now, the line its title shows: players to wait for, a peer silent and for how long, one that left, worlds that differ. null when there is nothing to say.
sums[text]With sums: true, the checksum after every confirmed step since the game began, 16 hex digits each; else empty.

net.leave#

net.leave {} -> {step: integer, checksum: text} · write

Says goodbye to every peer and closes the session and its socket. The game stays where it stands; input.history is the confirmed inputs of every player, a recording frost test holds.

ResultTypeMeaning
stepintegerHow many fixed steps have run.
checksumtextThe world's checksum at this step, 16 hex digits: what frost run prints as world checksum. Equal checksums mean equal worlds, on any machine. A project's replay holds another number, the checksum of a whole run (run checksum), which sums the world at every step.

Generated from Coldwave 0.0.1 r289, 2026-11-30 by the binary itself: do not edit by hand.