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

changeResource

changeResource<Handle>(writer, 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 writes the step’s tick into the resource’s spentTick, which pauses its regeneration for its regenDelaySeconds. An entity without the resource is left alone. A predicted write, as startCooldown’s: call it from a predicted system, or, for a rule on the room alone, with the room’s step, and the player’s page makes it on the tick the player pressed. 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 handle widened past its type that holds health throws.

Type Parameter
Handle extends ResourceHandle
Parameter Type
writer PredictedStep
entity PredictedEntity
change ChangeOfResource<Handle>

void

changeResource<Handle>(writer, 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 writes the step’s tick into the resource’s spentTick, which pauses its regeneration for its regenDelaySeconds. An entity without the resource is left alone. A predicted write, as startCooldown’s: call it from a predicted system, or, for a rule on the room alone, with the room’s step, and the player’s page makes it on the tick the player pressed. 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 handle widened past its type that holds health throws.

Type Parameter
Handle extends ResourceHandle
Parameter Type
writer EntityAuthority
entity Entity
change ChangeOfResource<Handle>

void