Verse Library verse

02 Fragment

Handles button presses, checks player health, and activates a device if conditions are met.

verse-library/events/02-fragment.verse

HandleButtonPress(Agent : agent) : void =
    # Cast agent -> player -> fort_character to read health.
    # The [] brackets mean these calls can fail; the if-block
    # only runs when every step succeeds.
    if (Player := player[Agent],                       # agent must be a player
        Character := Player.GetFortCharacter[],        # player must have a character
        Character.GetHealth() < 50.0):                 # health check
        PropMover.Activate(Agent)

Comments

    Sign in to vote, comment, or suggest an edit. Sign in