defineTrait
Call Signature
Section titled “Call Signature”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
undefined |
options |
PredictedTraitOptions<never, never> |
Returns
Section titled “Returns”PredictedTrait<Record<string, never>>
Call Signature
Section titled “Call Signature”defineTrait<
S,Listed,Types>(name,schema,options):WithNumberTypes<PredictedTrait<Norm<S>>,Types>
A predicted trait with fields, as its options say.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
S extends Schema |
- |
Listed extends string |
never |
Types extends TraitNumberTypes<TraitRecord<S>> |
NoNumberTypes |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
S & RefusePlayerText<S> & RefuseStreamedLiveObject<S> & RefusePredictedCollection<S> |
options |
PredictedTraitOptions<TraitRecord<S>, Listed, Types> |
Returns
Section titled “Returns”WithNumberTypes<PredictedTrait<Norm<S>>, Types>
Call Signature
Section titled “Call Signature”defineTrait(
name,schema,options):LocalTrait<TagTrait>
A tag no stream carries, which any step writes.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
undefined |
options |
TraitOptions<never, never, TraitNumberTypes<never>> & object |
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”defineTrait(
name,schema,options):AuthorityOnlyTrait<TagTrait>
A tag on the authority alone, which any step there writes.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
undefined |
options |
TraitOptions<never, never, TraitNumberTypes<never>> & object |
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”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 Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
S extends Schema |
- |
Listed extends string |
never |
Types extends TraitNumberTypes<TraitRecord<S>> |
NoNumberTypes |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
S & RefusePlayerText<S> & RequireCollection<S> |
options |
TraitOptions<TraitRecord<S>, Listed, Types> & object |
Returns
Section titled “Returns”WithNumberTypes<WithFields<LocalTrait<Trait<Norm<S>>>, CollectionHandles<S, LocalTrait<Trait<Norm<S>>>>>, Types>
Call Signature
Section titled “Call Signature”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 Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
S extends Schema |
- |
Listed extends string |
never |
Types extends TraitNumberTypes<TraitRecord<S>> |
NoNumberTypes |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
S & RefusePlayerText<S> & RefuseCollection<S> |
options |
TraitOptions<TraitRecord<S>, Listed, Types> & object |
Returns
Section titled “Returns”WithNumberTypes<LocalTrait<Trait<Norm<S>>>, Types>
Call Signature
Section titled “Call Signature”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 Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
S extends Schema |
- |
Listed extends string |
never |
Types extends TraitNumberTypes<TraitRecord<S>> |
NoNumberTypes |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
S & RefusePlayerText<S> & RequireCollection<S> |
options |
TraitOptions<TraitRecord<S>, Listed, Types> & object |
Returns
Section titled “Returns”WithNumberTypes<WithFields<AuthorityOnlyTrait<Trait<Norm<S>>>, CollectionHandles<S, AuthorityOnlyTrait<Trait<Norm<S>>>>>, Types>
Call Signature
Section titled “Call Signature”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 Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
S extends Schema |
- |
Listed extends string |
never |
Types extends TraitNumberTypes<TraitRecord<S>> |
NoNumberTypes |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
S & RefusePlayerText<S> & RefuseCollection<S> |
options |
TraitOptions<TraitRecord<S>, Listed, Types> & object |
Returns
Section titled “Returns”WithNumberTypes<AuthorityOnlyTrait<Trait<Norm<S>>>, Types>
Call Signature
Section titled “Call Signature”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 Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
S extends Schema |
- |
Listed extends string |
never |
Types extends TraitNumberTypes<TraitRecord<S>> |
NoNumberTypes |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
S & RefusePlayerText<S> & RefuseStreamedLiveObject<S> & RefusePredictedCollection<S> |
options |
TraitOptions<TraitRecord<S>, Listed, Types> & object |
Returns
Section titled “Returns”WithNumberTypes<AnyEntityPredictedTrait<Trait<Norm<S>>>, Types>
Call Signature
Section titled “Call Signature”defineTrait(
name,schema?,options?):TagTrait
A tag: a trait with no fields.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema? |
undefined |
options? |
TraitOptions<never, never, TraitNumberTypes<never>> & PlainTraitOptions |
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”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 Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
S extends Schema |
- |
Listed extends string |
never |
Types extends TraitNumberTypes<TraitRecord<S>> |
NoNumberTypes |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
S & RefusePlayerText<S> & RefuseStreamedLiveObject<S> & RequireCollection<S> |
…options |
UnpredictedOptionsArgument<TraitRecord<S>, Listed, Types> |
Returns
Section titled “Returns”WithNumberTypes<WithFields<Trait<Norm<S>>, CollectionHandles<S, Trait<Norm<S>>>>, Types>
Call Signature
Section titled “Call Signature”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 Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
S extends Schema |
- |
Listed extends string |
never |
Types extends TraitNumberTypes<TraitRecord<S>> |
NoNumberTypes |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name |
string |
schema |
S & RefusePlayerText<S> & RefuseStreamedLiveObject<S> & RefuseCollection<S> |
…options |
PlainOptionsArgument<TraitRecord<S>, Listed, Types> |
Returns
Section titled “Returns”WithNumberTypes<Trait<Norm<S>>, Types>