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

changeResource

changeResource<Key>(entity, change): void

Adds amount of a resource to entity, up to its maximum less what its reservations hold back, or spends it where amount is negative, down to 0: a hit that builds rage, a sprint that spends stamina. A spend pauses its regeneration for its regenDelaySeconds. An entity without the resource is left alone. Call it from a system, where the simulation has the say. Health is an outcome, which a page in a room cannot change: dealDamage and dealHealing change it, with the room’s authority. healthResource is a type error here, and a key widened past its type that holds health throws.

Type Parameter
Key extends ResourceKey
Parameter Type
entity Entity
change ChangeOfResource<Key>

void