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

readTrait

readTrait<S>(entity, trait): DeepReadonly<TraitRecord<S>> | undefined

entity’s record of trait, read-only at any depth: for a view, a HUD, a test or any system. Undefined where it lacks the trait. It is the record itself, not a copy: the type alone keeps a reader from writing it.

Type Parameter
S extends Schema
Parameter Type
entity Entity
trait PredictedTrait<S> | CoreTrait<S>

DeepReadonly<TraitRecord<S>> | undefined

readTrait<T>(entity, trait): DeepReadonly<TraitRecord<T>> | undefined

entity’s record of trait, read-only at any depth: for a view, a HUD, a test or any system. Undefined where it lacks the trait. It is the record itself, not a copy: the type alone keeps a reader from writing it.

Type Parameter
T extends Trait
Parameter Type
entity Entity
trait T

DeepReadonly<TraitRecord<T>> | undefined