ReferenceVerse
Get Set Health
get set health
Updated
get-set-health in ~90 seconds.One press on the Golden Hour Jetty heal station and your battered pirate’s health bar instantly snaps back to full — here's the Verse code that reads and refills their vitality.
The button device fires an event that lets us grab the player's fort character, read their current and max health, and push it to the limit.
We subscribe to the interaction, unwrap the agent, check if they need healing, and call SetHealth with the max value.
Reach for GetHealth and SetHealth whenever you need to read a player's vitality or snap it to a specific value during gameplay.
heal_station := class(creative_device):
@editable
HealButton : button_device = button_device{}
OnPressed(Agent : ?agent) : void =
if (Player := Agent?, Char := Player.GetFortCharacter[]):
Current := Char.GetHealth()
Max := Char.GetMaxHealth()
if (Current < Max):
Char.SetHealth(Max)
OnBegin<override>()<suspends>:void =
HealButton.InteractedWithEvent.Subscribe(OnPressed)
Build your own lesson with get-set-health
Generate a personalized, compile-checked lesson grounded in this exact reference.
Build a lesson →