Verse Library verse

01 Fragment

Subscribes to trigger overlap events to handle player entry and exit logic.

verse-library/post-process-effects/01-fragment.verse

# We need to import the core Verse libraries for basic logic and player interaction.
use core:/engine/core.verse
use player:/engine/player.verse
use world:/engine/world.verse
use game:/engine/game.verse

# Define our script. This is the "brain" of our island.
script CreepyZoneScript:
    # This function runs when the island starts.
    OnStart():
        # 1. Find the Trigger Volume by its name.
        # We use `Find` to search the world for an object named "CreepyZoneTrigger".
        trigger := world.Find("CreepyZoneTrigger")
        
        # Safety check: If the trigger doesn't exist, stop and show an error.
        # This is like checking if you have your keys before leaving the house.
        if (trigger == None):
            print("Error: CreepyZoneTrigger not found in the world!")
            return
        
        # 2. Subscribe to the Trigger's "OnBeginOverlap" event.
        # This means: "Hey Verse, call the HandleOverlap function when someone walks in."
        trigger.OnBeginOverlap += HandleOverlap
        
        # 3. Subscribe to the Trigger's "OnEndOverlap" event.
        # This means: "And call HandleExit when someone walks out."
        trigger.OnEndOverlap += HandleExit

    # This function runs when a player enters the zone.
    HandleOverlap(overlap_player: player.Player):

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

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