ReferenceDevices
Apply Damage
apply damage
Updated
apply_damage in ~90 seconds.Step on the glowing starfish at Seashell Shore, and watch your health bar instantly drop by half.
The trigger device detects the player, and we use the damageable interface—which also lets you check GetHealth or listen for DamagedEvent—to subtract health directly.
We subscribe to the trigger, unwrap the agent into a fort character, and call Damage with our float amount.
Reach for the Damage method whenever you need code to directly lower health without a weapon.
trap_demo := class(creative_device):
@editable
Trap : trigger_device = trigger_device{}
OnStepped(Agent : ?agent) : void =
if (A := Agent?, Char := A.GetFortCharacter[]):
Char.Damage(50.0)
OnBegin<override>()<suspends>:void =
Trap.TriggeredEvent.Subscribe(OnStepped)
Build your own lesson with apply_damage
Generate a personalized, compile-checked lesson grounded in this exact reference.
Build a lesson →