Verse Library verse

01 Fragment

Tracks player item pickups on the island using an actor with incrementing counters.

verse-library/lesson-landing-humanities-arts-design-in-fortnite-creative/01-fragment.verse

// 1. IMPORTS: We need access to basic game tools.
// Think of this as grabbing your tools from the toolbox before starting.
using { /Fortnite.com/Devices }
using { /Verse.org/Sim }

// 2. THE ENTITY: This is the "Loot Goblin" itself.
// In the Scene Graph, this Entity is the "child" of the Island.
// It's the thing we are attaching this script to.
actor LootGoblin : Island() =
    // 3. VARIABLES: The Goblin's "memory."
    // 'ItemCount' is a variable that starts at 0.
    // It's like the player's inventory counter, but attached to the Goblin.
    ItemCount : int = 0
    
    // 'MaxItems' is a CONSTANT.
    // It's set once and never changes. Like the storm damage value.
    MaxItems : int = 5
    
    // 4. INITIALIZATION: This runs once when the island starts.
    // It's like the "Start of Match" cutscene.
    OnBegin<override>()=
        # Say hello to the console/log so we know it's working.
        Print("Loot Goblin is awake and watching your greed.")

    // 5. EVENT HANDLER: This is the core logic.
    // We are listening for a specific event: 'OnItemPickedUp'.
    // Every time a player picks up an item anywhere on the island,
    // this function gets called.
    OnItemPickedUp<override>()=
        # INCREMENT: This means "add 1 to the current value."

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