Verse Library verse

01 Standalone

Displays objective instructions via HUD devices automatically when players join the match.

verse-library/9-creating-visual-aids/01-standalone.verse

# Import the core Verse libraries we need
use: core
use: player
use: device

# Define our script. This is the brain of our island.
# 'concrete' means this is a real, active object in the scene.
ObjectiveGuide := class<concrete>:
    # This is a 'Variable'. Think of it as a backpack slot.
    # We are storing a reference to our HUD Message device.
    # 'device_handle' is like a remote control for the device.
    objective_message: device_handle<HUD_Message> = device_handle{}

    # This is a 'Function'. It’s a set of instructions we can run.
    # 'Activate' is a special function that runs when the device starts up.
    Activate(): void =
        # 'Get_Device()' looks in the scene for the device named 'objective_message'
        # and gives us control over it.
        hud := Get_Device(objective_message)

        # Now we check if we actually found the device.
        # If 'hud' is valid, we proceed.
        if (hud.IsValid()):
            # We want to show the message when a player joins.
            # We connect the 'OnPlayerJoined' event to a function we'll write next.
            hud.OnPlayerJoined.Bind(ShowObjective)

    # This is the function that actually shows the text.
    # 'p' stands for 'player'. Every time a player joins, Verse calls this.
    ShowObjective(p: player): void =

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