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 that holds its entity. The options are optional: reach names who receives it, from Reach, and predicted has the player’s page predict it on the player’s 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, Types>(name, schema, options): WithNumberTypes<PredictedTrait<Norm<S>>, Types>

A predicted trait with fields, as its options say.

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

WithNumberTypes<PredictedTrait<Norm<S>>, Types>

defineTrait(name, schema, options): LocalTrait<TagTrait>

A tag no stream carries, which any step writes.

Parameter Type
name string
schema undefined
options TraitOptions<never, never, TraitNumberTypes<never>> & object

LocalTrait<TagTrait>

defineTrait(name, schema, options): AuthorityOnlyTrait<TagTrait>

A tag on the authority alone, which any step there writes.

Parameter Type
name string
schema undefined
options TraitOptions<never, never, TraitNumberTypes<never>> & object

AuthorityOnlyTrait<TagTrait>

defineTrait<S, Listed, Types>(name, schema, options): WithNumberTypes<WithFields<LocalTrait<Trait<Norm<S>>>, CollectionHandles<S, LocalTrait<Trait<Norm<S>>>>>, Types>

A trait with a list or a grid no stream carries, which any step writes, with each collection’s handle under fields.

Type Parameter Default type
S extends Schema -
Listed extends string never
Types extends TraitNumberTypes<TraitRecord<S>> NoNumberTypes
Parameter Type
name string
schema S & RefusePlayerText<S> & RequireCollection<S>
options TraitOptions<TraitRecord<S>, Listed, Types> & object

WithNumberTypes<WithFields<LocalTrait<Trait<Norm<S>>>, CollectionHandles<S, LocalTrait<Trait<Norm<S>>>>>, Types>

defineTrait<S, Listed, Types>(name, schema, options): WithNumberTypes<LocalTrait<Trait<Norm<S>>>, Types>

A trait with fields no stream carries, which any step writes.

Type Parameter Default type
S extends Schema -
Listed extends string never
Types extends TraitNumberTypes<TraitRecord<S>> NoNumberTypes
Parameter Type
name string
schema S & RefusePlayerText<S> & RefuseCollection<S>
options TraitOptions<TraitRecord<S>, Listed, Types> & object

WithNumberTypes<LocalTrait<Trait<Norm<S>>>, Types>

defineTrait<S, Listed, Types>(name, schema, options): WithNumberTypes<WithFields<AuthorityOnlyTrait<Trait<Norm<S>>>, CollectionHandles<S, AuthorityOnlyTrait<Trait<Norm<S>>>>>, Types>

A trait with a list or a grid on the authority alone, with each collection’s handle under fields.

Type Parameter Default type
S extends Schema -
Listed extends string never
Types extends TraitNumberTypes<TraitRecord<S>> NoNumberTypes
Parameter Type
name string
schema S & RefusePlayerText<S> & RequireCollection<S>
options TraitOptions<TraitRecord<S>, Listed, Types> & object

WithNumberTypes<WithFields<AuthorityOnlyTrait<Trait<Norm<S>>>, CollectionHandles<S, AuthorityOnlyTrait<Trait<Norm<S>>>>>, Types>

defineTrait<S, Listed, Types>(name, schema, options): WithNumberTypes<AuthorityOnlyTrait<Trait<Norm<S>>>, Types>

A trait with fields on the authority alone, which any step there writes.

Type Parameter Default type
S extends Schema -
Listed extends string never
Types extends TraitNumberTypes<TraitRecord<S>> NoNumberTypes
Parameter Type
name string
schema S & RefusePlayerText<S> & RefuseCollection<S>
options TraitOptions<TraitRecord<S>, Listed, Types> & object

WithNumberTypes<AuthorityOnlyTrait<Trait<Norm<S>>>, Types>

defineTrait<S, Listed, Types>(name, schema, options): WithNumberTypes<AnyEntityPredictedTrait<Trait<Norm<S>>>, Types>

A predicted trait any entity may hold, which a predicted step writes on the entity it hands out and an authority writes on any.

Type Parameter Default type
S extends Schema -
Listed extends string never
Types extends TraitNumberTypes<TraitRecord<S>> NoNumberTypes
Parameter Type
name string
schema S & RefusePlayerText<S> & RefuseStreamedLiveObject<S> & RefusePredictedCollection<S>
options TraitOptions<TraitRecord<S>, Listed, Types> & object

WithNumberTypes<AnyEntityPredictedTrait<Trait<Norm<S>>>, Types>

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

A tag: a trait with no fields.

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

TagTrait

defineTrait<S, Listed, Types>(name, schema, …options): WithNumberTypes<WithFields<Trait<Norm<S>>, CollectionHandles<S, Trait<Norm<S>>>>, Types>

A trait with a list or a grid among its fields, koota’s own trait, with each collection’s handle under fields, as ChunkTrait.fields.blocks.

Type Parameter Default type
S extends Schema -
Listed extends string never
Types extends TraitNumberTypes<TraitRecord<S>> NoNumberTypes
Parameter Type
name string
schema S & RefusePlayerText<S> & RefuseStreamedLiveObject<S> & RequireCollection<S>
…options UnpredictedOptionsArgument<TraitRecord<S>, Listed, Types>

WithNumberTypes<WithFields<Trait<Norm<S>>, CollectionHandles<S, Trait<Norm<S>>>>, Types>

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

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
Types extends TraitNumberTypes<TraitRecord<S>> NoNumberTypes
Parameter Type
name string
schema S & RefusePlayerText<S> & RefuseStreamedLiveObject<S> & RefuseCollection<S>
…options PlainOptionsArgument<TraitRecord<S>, Listed, Types>

WithNumberTypes<Trait<Norm<S>>, Types>