Verse Library verse

01 Device

Links a button device to an item granter to award players with items upon interaction.

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

# This is our main script file.
# It connects the button to the item dispenser.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# We define a new "Thing" called CuddleDispenser.
# A "Thing" is a container for our code.
# creative_device is the real base class for island scripts in Verse.
cuddle_dispenser := class(creative_device):

    # This is the button player will press.
    # We link it to the Button device in the editor.
    @editable
    MyButton : button_device = button_device{}

    # This is the device that gives the item.
    # We link it to the Grant Item device.
    @editable
    MyGranter : item_granter_device = item_granter_device{}

    # This function runs when the game starts.
    # It sets up the connection.
    OnBegin<override>()<suspends> : void =
        # We wait for the button to be pressed.
        # When it is pressed, we run the "GiveItem" function.
        MyButton.InteractedWithEvent.Subscribe(GiveItem)

    # This function actually gives the item.

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