Verse Library verse

01 Device

Distributes consumable loot to players automatically when they respawn via a spawn pad.

verse-library/using-travel-consumables-in-fortnite-creative/01-device.verse

# This is a comment. It's like a sticky note for yourself.
# The compiler (the program that checks your code) ignores these.

# We need to tell Verse which "parts" of Fortnite we want to use.
# Think of this as checking your backpack before a match.
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# This is the main "Brain" of our script.
# It attaches to a Device (like a Trigger or a Spawn Pad)
# so it knows when to wake up.
RespawnLootDevice := class(creative_device):

    # This is the "Trigger" that watches for players.
    # It's like a sensor that says "Hey, someone just came back!"
    # Wire this slot to a Spawn Pad device in the UEFN Details Panel.
    @editable
    SpawnPad : spawn_pad_device = spawn_pad_device{}

    # OnBegin runs once when the game session starts.
    # We use it to subscribe to the SpawnPad's SpawnedEvent.
    OnBegin<override>()<suspends> : void =
        # Subscribe: every time the SpawnPad fires SpawnedEvent,
        # call our give_respawn_loot function with the player who spawned.
        SpawnPad.SpawnedEvent.Subscribe(OnPlayerSpawned)

    # This is the "Event Listener."
    # It's like a security camera recording.

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