Verse Library verse

01 Fragment

Validates ingredients in player inventory, removes them, and grants the crafted result.

verse-library/using-food-crafting-consumables-in-fortnite-creative/01-fragment.verse

using { /Fortnite.com/Devices }
using { /Fortnite.com/Items }
using { /Fortnite.com/Player }

# This script makes a crafting button smarter.
# It checks for a second ingredient (Milk) that the device can't see,
# then removes both ingredients and grants the result.

# Define the items we need for our recipe
const Wheat_Item := "Wheat"
const Milk_Item := "Milk"
const Bread_Item := "Bread"

# This is the main event handler. It runs when the button is pressed.
OnActivated := (event:ActivatedEvent) -> result: void = {
    # Get the player who pressed the button
    player := event.Get_Owner()

    # Check if the player exists (safety first, like checking for a shield)
    if (player == none) {
        return
    }

    # Get the player's inventory component
    inventory := player.Get_Inventory()

    # Check if the player has Wheat (1) and Milk (1)
    # We assume Wheat was already checked by the Conditional Button,
    # but let's verify Milk here to be safe.
    has_wheat := inventory.Has_Item(Wheat_Item, 1)

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