Verse Library verse

01 Fragment

Awards a specified item to players entering a designated area or overlapping a trigger volume.

verse-library/using-farm-prefabs-in-fortnite-creative/01-fragment.verse

# BarnTrapScript.v
# This script makes a barn give players a Confetti Cannon when they enter.

use Fortitude // The library that lets us talk to Fortnite devices
use FortniteGame // The library for game-specific logic like items and players

# This is our "Entity" definition.
# Think of this as the blueprint for our trap.
# "BarnTrap" is the name of our script type.
BarnTrap = script:
    # This is a "Variable" (a container for data).
    # We will store the Item Granter device here.
    # In Verse, variables need a type. Here, it's a "Device".
    # A Device is any interactive object in Creative (like a button, speaker, or granter).
    ItemGranter: Device = Device{}

    # This is a "Function" (a reusable block of code).
    # Functions are like recipes. You define the steps once, then call them.
    # This function will handle giving the item.
    GiveLoot = function():
        # We check if the ItemGranter exists and is valid.
        if ItemGranter.IsValid():
            # "Grant" is a method (a function attached to a device).
            # We are telling the granter to give an item.
            # We need to specify the item ID.
            ItemGranter.GrantItem("ItemID_ConfettiCannon")

    # This is an "Event Handler".
    # It listens for the player entering the volume.
    # "OnBeginOverlap" is the event. It fires when two things touch.

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