Verse Library verse

01 Fragment

Tracks player joins and updates a UI text label with the total visit count.

verse-library/overview/01-fragment.verse

# Import the basic Verse libraries we need
using /Fortnite.com/Devices
using /Engine/Systems/LongGameInstance

# Define our device. This is the "Entity" we are attaching code to.
# It inherits from GameDevice, which gives us access to game events.
device VisitCounter : GameDevice() =
    # This is our VARIABLE.
    # It starts at 0 and can hold whole numbers (int).
    # Think of this as the "Visit Count" in the analytics dashboard.
    VisitCount: int = 0

    # This is the TEXT LABEL we want to update.
    # Drag and drop a Text Label device from the palette into this slot
    # in the Unreal Editor when you attach this script.
    DisplayLabel: TextLabelDevice

    # This is a FUNCTION.
    # It’s a recipe for updating the screen.
    # It takes no inputs and returns nothing (void).
    UpdateDisplay() =
        # Convert the number to text so the label can read it.
        # Then set the label's text property.
        DisplayLabel.SetText("Visits: " + ToString(VisitCount))

    # This is an EVENT LISTENER.
    # It waits for the "OnBeginPlay" event (when the game starts).
    # It also waits for "OnPlayerJoined" (when someone hits play).
    OnBeginPlay() =
        # When the game starts, we initialize the count.

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