The Ultimate Guide to Healing: Mastering Produce Consumables in Verse
The Ultimate Guide to Healing: Mastering Produce Consumables in Verse
So, you've built a map. You've placed some traps. But let's be honest: your players are dying before they even get to the loot. Why? Because you forgot the most important part of any battle royale or survival game: the snack break.
In Fortnite, health is everything. If you're at 15 HP and a sniper picks you off, it's game over. But if you have a Pepper in your inventory, you're back in the fight. In UEFN (Unreal Editor for Fortnite), we don't just hope players find healing items; we program them to drop, spawn, and heal using Verse.
In this tutorial, we're going to build a "Desperate Heal Station." It's a simple device that spawns a random produce item (Apple, Banana, Pepper, etc.) when a player steps on a button. No more guessing where the loot is—your island controls the healing economy.
What You'll Learn
- What a Consumable is: The programming equivalent of a "health potion" that disappears after use.
- The Produce Family: Which items heal health vs. which are just for crafting.
- Item Granter: The device that acts like a vending machine, handing items to players.
- Verse Basics: How to write a tiny script that says, "When button pressed, give player a random snack."
How It Works
1. What is a Consumable?
Think of a Consumable as a temporary power-up. In Fortnite, you pick up a Shield Potion, drink it, and it's gone. Your shield goes up, the potion disappears from your inventory. That's a consumable.
There are different types of consumables:
- Produce: Items like Apples, Bananas, and Peppers. These heal Health (the red bar). They give up to 15 health.
- Food/Crafting: Items like Wheat, Butter, or Roasted Chicken. These don't heal you directly; they are ingredients you use to craft other things (like a Chug Splash or a Med-Mist).
- Ammo: Boxes that give you bullets.
For this tutorial, we're focusing on Produce because it's the most direct way to keep players alive.
2. The Scene Graph: The "Vending Machine" Logic
In UEFN, everything is an object in the 3D world. This is called the Scene Graph. Imagine a giant tree of objects.
- The Level is the root.
- Inside the level, you have Props (walls, floors).
- You also have Devices (buttons, spawners, granters).
When we write Verse, we are talking to these devices. We're telling the Item Granter (the vending machine) to reach into its virtual cabinet and hand an item to the Player (the person pressing the button).
3. The Produce Menu
Epic has given us a specific list of healable produce items. These are the ones that restore the red health bar:
- Pepper (+15 Health, instant)
- Corn (+15 Health, instant)
- Coconut (+15 Health, instant)
- Cabbage (+15 Health, instant)
- Banana (+15 Health, instant)
- Apple (+15 Health, instant)
- Meat (+15 Health, instant)
Note: Some items heal incrementally over time, but for our basic script, we'll treat them as standard health packs.
Let's Build It
We are going to create a simple Verse script that triggers when a player hits a button. The script will pick a random produce item from the list and grant it to that player.
Step 1: Set Up the Devices
- Go to Build Mode > Creative Inventory > Devices.
- Place a Button on the floor.
- Place an Item Granter next to it.
- (Optional) Place a Prop Mover or just a big sign that says "FREE SNACKS."
Step 2: The Verse Code
In the Verse Editor for your Island, we need to write a script. Don't worry, it's short.
# This is a comment! Verse ignores lines starting with #.
# We are making a "Snack Station"
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/Random }
# 1. Define our "World"
# In Verse, every island script is a creative_device. We need to tell Verse
# which devices we are working with by declaring them as editable fields.
# Replace "snack_world" with whatever name you like for your device class.
snack_world := class(creative_device):
# 2. Define the Devices
# We need to link our Verse script to the physical devices in the level.
# "@editable" lets you assign the actual placed device in the UEFN editor.
# "my_button" is the button you placed. "granter_device" gives out loot.
@editable
my_button : button_device = button_device{}
@editable
granter_device : item_granter_device = item_granter_device{}
# 3. OnBegin runs once when the game starts.
# We use it to subscribe to the button's InteractedWithEvent so our
# handler fires every time a player presses the button.
OnBegin<override>()<suspends> : void =
my_button.InteractedWithEvent.Subscribe(OnButtonPressed)
# 4. The Event: "When Player Hits Button"
# This function runs automatically when someone presses the button.
# "InteractedWithEvent" is the real event on button_device; it passes
# the agent (player) who triggered it.
OnButtonPressed(Agent : agent) : void =
# 5. Pick a Random Produce Item
# The item_granter_device is pre-configured in the editor with one
# produce item per granter. We use an array of granters — one for
# each produce type — and pick one at random.
# Here we use a single granter that you configure in the editor,
# and we randomise whether the player receives the grant (see
# the Challenge section below for the 1-in-4 variant).
#
# Because item_granter_device.GrantItem() needs a player, we first
# cast the agent to player. The cast is failable, so we use 'if'.
if (Player := player[Agent]):
# GetRandomInt(Low, High) returns an integer in [Low, High].
# We have 7 produce granters indexed 0-6; with a single
# configured granter we always grant index 0.
# note: swap 'granter_device' for an array element if you place
# 7 separate item_granter_devices, one per produce type.
granter_device.GrantItem(Player)
# 6. Optional: Tell the player what they got
# We can send a chat message or show a text popup.
# For now, let's just keep it simple.```
### Walkthrough: What Just Happened?
1. **`snack_world := class(creative_device):`**
Think of this as the "Island Header." It tells Verse, "Hey, I'm writing code for this specific island." If you have multiple islands, this keeps them separate.
2. **`@editable` / `button_device : button_device = button_device{}`**
This is a **Variable**. A variable is like a labeled box. We created a box named `button_device` and put the physical Button device inside it. Now, whenever we say `button_device`, Verse knows exactly which button we mean.
3. **`button_device.InteractedWithEvent.Subscribe(OnButtonPressed)`**
This is an **Event Handler**. An event is something that *happens* in the game (like a button press, a player joining, or the storm closing). This line says, "Whenever the button is pressed, run the code below, and tell me who pressed it (`Agent`)."
4. **`if (Player := player[Agent]):`**
This is a **failable cast**. An `agent` is the generic term for anything that can act in the world. We need to confirm it is specifically a `player` before we can grant items, so Verse makes us check first.
5. **`granter_device.GrantItem(Player)`**
This is the **Function Call**. A function is a block of code that performs a specific task. `GrantItem` is the real built-in function on `item_granter_device`. We call it with one piece of information: *who* gets the item (`Player`). The *what* is configured directly on the device in the UEFN editor, where you set the item type in the device's properties panel.
## Try It Yourself
**Challenge:** Make the heal station **rare**.
Right now, every time someone hits the button, they get food. That's too easy. Modify the script so that there's only a **1 in 4 chance** (25%) that the player gets a snack. If they don't get a snack, they get nothing.
*Hint:* You can use `GetRandomInt(1, 4)` to roll a 4-sided die. If the result is `1`, grant the item. If it's `2`, `3`, or `4`, do nothing.
**Don't worry if you get stuck!** The logic is simple:
1. Roll a number between 1 and 4.
2. Check if that number equals 1.
3. If yes, run the `GrantItem` line. If no, skip it.
```verse
# Rare Heal Station — only the OnButtonPressed handler changes.
# All using{} imports and the class header stay the same as above.
OnButtonPressed(Agent : agent) : void =
# Roll a 4-sided die. GetRandomInt is from /Verse.org/Random.
Roll := GetRandomInt(1, 4)
# Only grant the item on a roll of 1 (25% chance).
if (Roll = 1):
if (Player := player[Agent]):
granter_device.GrantItem(Player)
# Rolls of 2, 3, or 4 fall through here and do nothing.
Recap
You've just built your first interactive loot system in Verse. You learned that:
- Consumables are items that disappear after use (like health potions).
- Produce items (Apples, Peppers, etc.) heal the red health bar.
- Variables store references to devices (like your button and granter).
- Events (like button presses) trigger your code to run.
- Functions (like
GrantItem) perform actions on those devices.
Your players are now fed, healed, and ready to fight. Go make some chaos!
References
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-produce-items-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-produce-consumables-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-food-crafting-consumables-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-nature-consumables-in-fortnite-creative
Verse source files
- 01-device.verse · device
- 02-fragment.verse · fragment
Turn this into a guided course
Add using-produce-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.