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

defineTrait

defineTrait(name, schema, options): PredictedTrait<Record<string, never>>

Makes a trait, as koota’s trait does, and names it: the dump and the devtools show it under name, and a room streams it to every page. The options are optional: ownerOnly streams it to its character’s player alone, serverOnly keeps it on the room, local has the room and each page keep their own, and predicted has her page predict it on her character. A trait with a field that holds an entity, or a list of them, takes options, whose entities names each such field. A predicted trait is a PredictedTrait, which only a predicted step and grantPredicted write, unless anyEntity keeps it koota’s own. With no schema it is a tag. Called once, at module scope, in a module the room and the page both import. The common call is an ordinary trait, defineTrait("score", { points: 0 }), the last signature here; this one makes a predicted tag.

Parameter Type
name string
schema undefined
options PredictedTraitOptions<never, never>

PredictedTrait<Record<string, never>>

defineTrait<S, Listed>(name, schema, options): PredictedTrait<Norm<S>>

A predicted trait with fields, as its options say.

Type Parameter Default type
S extends Schema -
Listed extends string never
Parameter Type
name string
schema S & RefusePlayerText<S>
options PredictedTraitOptions<TraitRecord<S>, Listed>

PredictedTrait<Norm<S>>

defineTrait(name, schema?, options?): TagTrait

A tag: a trait with no fields.

Parameter Type
name string
schema? undefined
options? TraitOptions<never, never> & PlainTraitOptions

TagTrait

defineTrait<S, Listed>(name, schema, …options): Trait<Norm<S>>

A trait with fields that is not predicted, or is predicted with anyEntity: koota’s own trait.

Type Parameter Default type
S extends Schema -
Listed extends string never
Parameter Type
name string
schema S & RefusePlayerText<S>
…options PlainOptionsArgument<TraitRecord<S>, Listed>

Trait<Norm<S>>