The Ultimate Kitchen Chaos: Building a Crafting System with Verse
The Ultimate Kitchen Chaos: Building a Crafting System with Verse
Stop dropping loot boxes and start dropping recipes. If you’ve ever played a survival game where you had to collect three wolf pelts and a stick to make a better bow, you already understand crafting. In Fortnite Creative, we usually rely on devices to check if a player has the right items. But what if you want to make that logic dynamic, scalable, and actually fun to code?
In this tutorial, we’re going to build a Crafting Station. It’s a simple device that checks if a player has the specific ingredients (like Wheat and Milk) to craft a higher-tier item (like Bread). We’ll use Verse to handle the inventory logic, turning your island into a culinary battlefield. No more guessing if the player has the right stuff—your code will know.
What You'll Learn
- Inventory Variables: How to track what a player is holding using Verse variables.
- Conditional Logic: Using
ifstatements to check for specific items (like checking if the storm is closing). - Item Manipulation: Removing ingredients and granting rewards programmatically.
- Scene Graph Basics: Understanding how your Verse script interacts with the physical devices in your level.
How It Works
Think of your island like a lobby. The Scene Graph is the list of every object in that lobby—walls, props, devices, and players. In UEFN, these are all "Entities." A Verse Script is like a rulebook or a referee that lives inside one of those entities.
When a player walks up to your crafting table, they trigger an Event (like stepping on a pressure plate). Your script listens for that event. Once triggered, it doesn't just guess; it looks at the player's inventory.
In Fortnite, items are identified by unique IDs. We need to check:
- Does the player have Ingredient A?
- Does the player have Ingredient B?
If both are true, we perform two actions:
- Consume: Remove Ingredient A and B from their inventory (like eating a chug splash).
- Grant: Add the Crafted Item to their inventory (like getting a kill reward).
If they don’t have the items, we do nothing—no penalty, just a failed attempt. Simple, clean, and efficient.
Let's Build It
We are going to create a script attached to a Conditional Button. This button will only activate if the player has the required items. However, Verse gives us more control than the device alone. We will use Verse to force the removal of items and the granting of the reward, ensuring the transaction is atomic (it either happens fully or not at all).
The Setup
- Place a Conditional Button in your island.
- In the Details panel, set the Required Item to
Wheat(we’ll handle the second item in code, or you can set up multiple conditions). - Place an Item Granter next to it. Set its output to grant
Bread. - Connect the Conditional Button to the Item Granter.
- Create a new Verse script and attach it to the Conditional Button.
The Verse Code
Here is the script. It listens for the button activation, verifies the player has the second ingredient (Milk), and then manually handles the swap.
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)
has_milk := inventory.Has_Item(Milk_Item, 1)
# If we have BOTH ingredients, craft the bread!
if (has_wheat && has_milk) {
# Remove the ingredients
inventory.Remove_Item(Wheat_Item, 1)
inventory.Remove_Item(Milk_Item, 1)
# Grant the crafted item
inventory.Grant_Item(Bread_Item, 1)
# Optional: Send a message to the player
# player.Send_Server_Message("Crafted Bread!")
} else {
# If missing items, maybe play a sound or do nothing
# We don't want to remove items if the recipe is incomplete!
}
}
Walkthrough
using { ... }: These are imports. Think of them as your loadout. You need the "Devices" and "Items" classes to talk to the game world.const: Constants are like your default loadout settings. They never change.Wheat_Itemis always "Wheat".OnActivated: This is the event listener. It’s like the trigger on a gun. When the button is pressed, this function runs.event.Get_Owner(): This tells us who pressed the button. Without this, the script wouldn't know whose inventory to check.inventory.Has_Item(): This is the core logic. It returnstrueif the player has the item,falseotherwise. It’s like checking your ammo count.Remove_Item&Grant_Item: These are the actions. We take the materials away and give the product. This happens instantly.
Try It Yourself
The current script requires Wheat to be set in the Conditional Button device itself. That’s a bit rigid.
Challenge: Modify the script so it doesn’t rely on the device’s "Required Item" setting. Instead, make the Verse script check for both Wheat and Milk entirely in code. Remove the "Required Item" from the device settings so it always activates when clicked, and let the Verse script decide if the craft is valid.
Hint: You’ll need to change the if condition to check for both items, and you might want to add a return statement if the check fails so the rest of the code doesn't run.
Recap
You’ve just built a dynamic crafting system. You learned how to use Verse to inspect a player’s inventory, check for multiple items, and manipulate those items programmatically. This is the foundation for complex systems: trading posts, upgrade stations, and loot goblins. By using Verse, you’re not just connecting wires; you’re writing the rules of your own universe.
References
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-food-crafting-consumables-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/using-food-crafting-items-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-consumables-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-crafting-consumables-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-wild-edible-crafting-consumables-in-fortnite-creative
Verse source files
- 01-fragment.verse · fragment
Turn this into a guided course
Add using-food-crafting-consumables-in-fortnite-creative to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.
References
Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.