Verse Library verse

01 Device

Grants an item when a player interacts with a button after meeting item requirements.

verse-library/using-wild-edible-crafting-items-in-fortnite-creative/01-device.verse

# This is a simple example of checking items
# In real UEFN, you mostly use the device settings!

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

crafting_station := class(creative_device):

    # Drag these devices into the slots in the UEFN editor
    @editable
    ConditionalButton : conditional_button_device = conditional_button_device{}

    @editable
    RewardGranter : item_granter_device = item_granter_device{}

    OnBegin<override>()<suspends> : void =
        # Listen for the event the conditional button fires when
        # all required items are present and the player presses it.
        # Configure the required items (Honey, Blue Mushroom, count 1 each)
        # in the Conditional Button device settings inside the UEFN editor.
        ConditionalButton.ItemRequirementPassedEvent.Subscribe(OnRecipeComplete)

    # Called when the conditional button confirms all ingredients are present
    OnRecipeComplete(Agent : agent) : void =
        Print("Recipe Complete!")
        # Grant the reward item configured in the Item Granter device settings
        RewardGranter.GrantItem(Agent)

Comments

    Sign in to vote, comment, or suggest an edit. Sign in