Verse Library verse

01 Device

Grants consumable items to triggering players while managing a limited stock counter.

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

# This is our main script. It lives on a device.
# We call this "MyTrapDispenser".
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Playspaces }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/Simulation }

MyTrapDispenser := class(creative_device):

    # This is our variable. It is like a counter.
    # We start with 1 item inside the machine.
    # var lets us change it later.
    var items_left : int = 1

    # This trigger device detects when a player
    # walks close enough to the dispenser.
    # Place a trigger_device in your island and
    # connect it to this property in UEFN.
    TriggerDevice : trigger_device = trigger_device{}

    # OnBegin runs automatically when the island starts.
    OnBegin<override>()<suspends> : void =
        # Subscribe to the trigger so we hear the "doorbell".
        TriggerDevice.TriggeredEvent.Subscribe(OnPlayerTouch)

    # This is our recipe.
    # It takes an agent (which includes players) as an input.
    GiveItem(Agent : agent) : void =
        # Try to get a fort_character from the agent so

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