Verse Library verse

01 Device

Links to a manager device to subtract points on player trigger entry, ideal for boss health systems.

verse-library/decrement-1/01-device.verse

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# This is our main script structure. 
# Think of it as the "Brain" of our island mechanic.
BossHealthScript := class(creative_device):

    # 1. VARIABLES: The "Backpack" for our data
    # We need to hold a reference to the Score Manager Device.
    # In game terms, this is like grabbing the remote control to the TV.
    HealthDevice: score_manager_device = score_manager_device{}

    # 2. INITIALIZATION: Setting up the game
    # This runs once when the level starts.
    OnBegin<override>()<suspends>:void=
        # We get the Score Manager Device from the creative space.
        # Note: In a real build, you'd link this to a specific device in the editor.
        # For this tutorial, we assume we have a device named "BossHealthMgr".
        # We are "binding" our variable to that physical device.
        return

    # 3. THE EVENT: "When something happens..."
    # This function runs every time the Trigger Volume is entered.
    # 'Player' is the person who walked in.
    OnPlayerEntered(Player: player):void=
        # 4. THE DECREMENT: The core mechanic
        # We tell the HealthDevice to subtract 1 from its current value.
        # It's like pressing the "-" button on a calculator.
        HealthDevice.Decrement()

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