Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

CommandOptions

What defineCommand takes beside the fields.

Type Parameter Default type
Reason extends string string
Returns extends ReturnFields | undefined ReturnFields | undefined
ActsThrough extends boolean boolean
Lifetime extends CommandLifetime CommandLifetime
Predicted extends boolean boolean
Property Type Default value Description
burst? number defaultCommandBurst, 2 How many the player may send at once past perSecond, from 1 to 16.
entity? ActsThrough false Whether it acts through one entity the sender controls, which the reader reads as command.entity and sendCommand names in its entity option, by type. The room runs it only while the sender controls that entity.
keys? readonly KeyCode[] undefined Keys that send it, on each first press of one, as ["KeyF"], checked against every other key the game binds as the world is made. Only on a command with no fields: a key sends no payload. One with entity: true goes through the entity the player’s held keys steer.
lateSeconds? number defaultLateSeconds, 0.28 For a predicted command: how many seconds after its own tick it may reach the room and still run, on the room’s next tick, above 0 and at most 1, counted in the room’s whole ticks. Later, it is refused late.
lifetime? Lifetime undefined What ends it before it runs, CommandLifetime: Control for one with entity: true, Session for any other. Entity and Control need entity: true; a predicted command keeps Control.
perSecond? number defaultCommandsPerSecond, 4, or defaultPredictedCommandsPerSecond, 20, for a predicted command Commands of this handle the player may send each second, above 0 and up to 60, such as 0.5 for one every two seconds: a guard against a flood, not a game rule.
predicted? Predicted false Whether it runs on the sender’s page on its tick as a guess, and on the room on the same tick, whose result confirms the guess or corrects it: an action the sender feels at once, such as a cast, a dash or a walk. Its one reader is a system marked predicted: true, which writes the entity’s predicted traits; it needs entity: true, its lifetime is Control, it waits for no deadline, and it returns no entity, since a re-run may not spawn.
refusals? readonly Reason[] [] The reasons its reader may refuse it with, kebab-case codes, beside the engine’s own CommandRefusal: ["occupied", "too-poor"].
returns? Returns undefined The fields of the value an accepted command carries back, such as { building: entity() }: its reader’s accept then takes the value, by type. Left out, an accepted command carries none.
rewind? RewindBounds defaultRewindBounds How far back the room may judge it: the bounds within the sender’s latency its view step is held to, which a query’s or a read’s rewind: command meets the world at. A target field’s own rewind holds that field’s entity.
timeoutSeconds? number defaultCommandTimeoutSeconds, 10 How long it may wait in its queue for its reader, from its admission, counted in the room’s ticks, before it is refused timed-out; at most 300.
touch? TouchButton undefined The touch button the engine draws for it on a phone, as <TouchControls /> places them. Only on a command with no fields, as keys.