← Back to path Download .md

Verse Basics

beginner 6 lessons ยท ~180 min ยท Generated 2026-06-21

Welcome to Verse programming for UEFN! In this learning path, you'll discover what Verse is, why it was created for Fortnite Creative, and how to write your own code to make amazing things happen on your island. By the end, you'll have written your very first device script and seen it work live in the game.

Learning Outcomes

Lesson 1: What is Verse and Why Use It?

Objectives

๐ŸŽฎ Welcome to Verse โ€” Your Game's Secret Superpower!

Have you ever played a Fortnite Creative island and thought, "I wish this game had a rule that didn't exist yet"? That's exactly why Verse was invented!


What Is Verse?

Verse is a programming language. Think of a programming language like a recipe book โ€” it gives you a special way to write instructions that a computer can read and follow.

But Verse isn't just any recipe book. It was built specifically for video games. That makes it extra great for making things happen inside Fortnite!


What Is UEFN?

UEFN stands for Unreal Editor for Fortnite. It's a super-powered building tool made by Epic Games. Imagine Fortnite Creative is a LEGO set. UEFN is like getting the pro builder kit โ€” way more pieces and tools!

Here's how the pieces fit together:

Together they make a team. You build the island in UEFN, and Verse tells the island how to behave.


Why Can't I Just Use Devices?

Great question! In Fortnite Creative, you already have devices. A device is a special object that does one job โ€” like a Trigger that fires when a player walks on it, or a Score Manager that tracks points.

Devices are awesome. But they only connect in set ways. It's like having LEGO pieces that only snap together in one direction. You can build cool things, but you can't build everything.

Verse fills the gap. It lets you write brand-new rules โ€” things no device can do on its own.

Here are some things Verse can help you do that devices can't easily do alone:


Verse and the Future ๐Ÿš€

Here's a cool bonus fact: Verse isn't just for Fortnite. Epic Games is building it into Unreal Engine 6, which is one of the most popular game-making tools in the whole world. Learning Verse now means you're learning a skill that will grow with you into real game development!


How Does Verse Fit Into UEFN?

Inside UEFN, you write Verse code in special files called .verse files. Think of each file like a page in your recipe book. Each page has instructions for one part of your island.

Your Verse file connects to devices on your island. When something happens in the game โ€” like a player stepping on a trigger โ€” your Verse code wakes up and runs its instructions.

It's like a sleeping robot that jumps to life the moment it hears the signal! ๐Ÿค–

Worked Example

๐Ÿ”ฌ Let's Look at a Real Verse File

Below is the simplest possible Verse device you can make in UEFN. It connects to your island and prints a message when the game starts. This is what a real .verse file looks like!

# This tells Verse: "this file is part of my island project"
using { /fortnite/devices }
using { /verse.org/simulation }
using { /verse.org/native }

# A "class" is like a blueprint for a custom device.
# 'creative_device' means this is a device that can live on your island.
my_first_device := class(creative_device):

    # 'OnBegin' is a special function that runs the moment your game starts.
    # Think of it like the starting pistol at a race โ€” BANG, go!
    OnBegin<override>()<suspends>:void=
        Print("My island is alive! Verse is working! ๐ŸŽ‰")

๐Ÿšถ Walk Through It Step by Step

  1. using { /fortnite/devices } โ€” This line imports tools from Fortnite. It's like opening your toolbox before you start building.

  2. my_first_device := class(creative_device): โ€” This creates a custom device (your own special island gadget). The := symbol means "make this thing and name it."

  3. OnBegin<override>()<suspends>:void= โ€” This is a function (a named set of instructions). OnBegin is the name Verse uses for "run this when the game begins."

  4. Print("My island is alive! ...") โ€” This sends a message to the output log. It's how you check that your code is running. Think of it as your island waving hello! ๐Ÿ‘‹

๐Ÿ’ก In UEFN: After writing this, you drag your device onto the island in the editor, hit Build Verse, then Play โ€” and you'll see your message appear in the output log!

Try It Yourself

๐Ÿ› ๏ธ Your Turn โ€” Build Your First Island Hello!

Goal: Set up a UEFN project and get a Verse device running on your island.

Steps to follow:

  1. Open UEFN and create a new project using a blank island template.
  2. In the top menu, go to Verse > Create New Verse File. Name it my_first_device.
  3. Look at the worked example above. Type the code into your new file. (Don't copy-paste โ€” typing it helps your brain learn it!)
  4. In UEFN, click Verse > Build Verse to check for errors.
  5. Drag your new device from the Content Browser onto the island floor.
  6. Press Launch Session to play. Open the Output Log and look for your printed message!

๐ŸŽฏ Checkpoint: Can you see your message in the Output Log? If yes โ€” you just ran your very first Verse program! ๐Ÿฅณ


๐ŸŒถ๏ธ Bonus Challenge:

Can you change the text inside Print(...) to say your own name and something fun? For example:

Print("Alex's island is LIVE! Let's gooo! ๐Ÿš€")

๐Ÿ’ก Hint: The message goes between the two quotation marks " ". Only change what's inside those marks โ€” leave everything else exactly the same!

Quiz

  1. What is Verse?
    • A. A new Fortnite weapon skin
    • B. A programming language for making game rules in UEFN
    • C. A device you place on your island like a trigger
    • D. A type of Fortnite Creative map
  2. Why would a game creator use Verse instead of just using devices?
    • A. Because devices don't work in UEFN at all
    • B. Because Verse makes your island look prettier
    • C. Because devices can only connect in set ways, but Verse lets you create brand-new rules
    • D. Because Verse is faster to learn than placing devices
  3. In Verse, what does the special function 'OnBegin' do?
    • A. It ends the game when a player wins
    • B. It runs your instructions the moment the game starts
    • C. It places a new device on the island
    • D. It saves your Verse file to the computer
  4. What does UEFN stand for?
    • A. Universal Engine For Navigating
    • B. Unique Effects For New games
    • C. Unreal Editor for Fortnite
    • D. Unreal Engine Fortnite Network
Answer key
  1. B โ€” Verse is a programming language โ€” like a special recipe book of instructions โ€” built specifically for making game rules and interactions in UEFN and Fortnite!
  2. C โ€” Devices are great, but they only snap together in pre-set ways โ€” like LEGO pieces with one direction. Verse lets you invent completely new rules that no device can do on its own!
  3. B โ€” OnBegin is like the starting pistol at a race. The moment the game begins, Verse runs whatever instructions you put inside OnBegin. That's why it's perfect for setup tasks!
  4. C โ€” UEFN stands for Unreal Editor for Fortnite. It's the pro-level building tool that combines Unreal Engine's power with Fortnite Creative โ€” and it's where you write Verse code!

Recap

๐ŸŒŸ Great Work โ€” Here's What You Learned!

Verse is a programming language made just for games, and it works inside UEFN โ€” the pro builder tool for Fortnite. Regular Creative devices are powerful, but they can only connect in set ways. Verse fills that gap by letting you write brand-new rules your island has never seen before. You even wrote your very first Verse device and sent a message from your island โ€” that's a huge first step! ๐ŸŽ‰

Sources

Lesson 2: Run Your First Verse Program

Objectives

๐ŸŽฎ Welcome to Your First Verse Program!

You are about to write real code โ€” the same kind of code that powers Fortnite islands! The language is called Verse. It is Epic Games' programming language for UEFN (Unreal Editor for Fortnite).

Don't worry if you have never coded before. We will go step by step. You've got this! ๐Ÿš€


๐Ÿงฐ What Is UEFN?

UEFN stands for Unreal Editor for Fortnite. Think of it like a giant toy factory. You use it to build your own Fortnite islands. Verse is the language you use to give your island a "brain" โ€” to make things happen in your game.


๐Ÿ“ฆ What Is a Verse Device?

A device is a special object you place on your island. Think of it like a LEGO brick with a tiny computer inside. When the game starts, the device's code runs automatically.

In this lesson, your device will print a message. Printing doesn't mean paper โ€” it means showing text in a special log screen inside the game. It's how programmers check that their code is working.


๐Ÿ—‚๏ธ Setting Up Your Project

Here's how to get started in UEFN:

  1. Open UEFN. In the Project Browser, click Feature Examples.
  2. Find and click Verse Device template, then give your project the name MyVerseProject. Click Create.
  3. In the Menu Bar at the top, go to Verse > Verse Explorer. This panel shows all your Verse files โ€” like a folder for your code.
  4. Right-click your project name in Verse Explorer. Choose Add new Verse file to project.
  5. In the window that pops up, click Verse Device, then click Create. This creates a starter code file called hello_world_device.verse. ๐ŸŽ‰
  6. Go to Verse > Build Verse Code so UEFN notices your new file.
  7. Open the Content Browser (bottom of the screen). Find your hello_world_device and drag it into your level (the big 3D world in the middle of UEFN).

๐Ÿ’ก Level means the map or island you are building. Dropping the device into it is like placing a LEGO brick on your baseplate.


๐Ÿƒ Running Your Island

  1. Click Launch Session in the toolbar. A window may ask you to save โ€” click Save Selected.
  2. When it loads, open the Main Menu and click Start Game.
  3. Once in the game, press Escape, click Island Settings, then click Log at the top.
  4. Look for the line that says "Hello, world!" followed by "2 + 2 = 4". Those came from your Verse code! Your program ran! ๐Ÿฅณ

๐Ÿ” What Is the Log?

The Log is like a notebook the game keeps while it runs. Your code can write notes into it. This is super useful โ€” it tells you "Hey, my code ran!" or "Here is what happened." Programmers call this logging or printing to the log.


โœ๏ธ Modifying Your Code

Now let's look at the code and change it!

  1. Go to Verse > Verse Explorer and double-click hello_world_device.verse. It opens in VS Code (Visual Studio Code) โ€” a free program for writing code. Think of VS Code like a super-smart notepad.
  2. You will see the starter code. We will look at it together in the next section.
  3. You can add a new Print line to show your own message. After you edit and save the file, go back to UEFN, click Verse > Build Verse Code, and launch your session again to see your changes!

๐Ÿ”‘ Key Words to Know

Word What It Means
Verse The coding language for Fortnite islands
Device A code-powered object you place on your island
Log A screen that shows messages from your code
Print Sending a text message to the Log
Build Verse Code Telling UEFN to read your latest code changes

Worked Example

๐Ÿ“– Let's Read the Starter Code

When you open hello_world_device.verse in VS Code, you see something like this:

# This is your first Verse device!
# Lines that start with # are called "comments."
# Comments are notes for humans โ€” the computer ignores them.

using { /Fortnite.com/Devices }       # Lets us use UEFN devices
using { /Verse.org/Simulation }        # Lets us use game timing tools
using { /UnrealEngine.com/Temporary/Diagnostics }  # Lets us use Print

# A "class" is like a blueprint for your device.
# creative_device is the base type โ€” all island devices inherit from it.
hello_world_device := class(creative_device):

    # OnBegin is a special function that runs automatically when the game starts.
    # Think of it like the "Start" signal on a race โ€” when the game goes, this runs!
    OnBegin<override>()<suspends>:void=
        Print("Hello, world!")    # Shows "Hello, world!" in the Log
        Print("2 + 2 = {2 + 2}") # Shows "2 + 2 = 4" โ€” Verse does the math!

๐Ÿงฉ Breaking It Down


๐ŸŽฏ What You Should See in the Log

After you Launch Session and Start Game, open the Log and you'll find:

Hello, world!
2 + 2 = 4

That means YOUR code ran in a real Fortnite island. You are officially a Verse programmer! ๐ŸŒŸ

Try It Yourself

๐Ÿ› ๏ธ Your Turn โ€” Make It Your Own!

You have seen how Print works. Now let's make the program say something new!

Your challenge:

  1. Open hello_world_device.verse in VS Code.
  2. Inside OnBegin, add two new Print lines below the existing ones.
    • One line should print your name (example: "My name is Alex!")
    • One line should print a math fact using { } (example: "5 + 3 = {5 + 3}")
  3. Save your file in VS Code (press Ctrl+S on Windows or Cmd+S on Mac).
  4. In UEFN, go to Verse > Build Verse Code.
  5. Click Launch Session, start the game, and check the Log for your new messages!

๐Ÿค” Hints:


๐ŸŒŸ Bonus Challenge:

Can you add a third Print line that says how old you are? Like: "I am 11 years old!"

(No math needed โ€” just type the number right in the message!)

Quiz

  1. What does the `Print` function do in Verse?
    • A. It sends your code to a printer.
    • B. It shows a text message in the game's Log screen.
    • C. It places a new device on your island.
    • D. It starts the game automatically.
  2. What is the name of the special function that runs automatically when your game starts?
    • A. StartGame
    • B. OnBegin
    • C. LaunchSession
    • D. Print
  3. You want your Print message to show the result of 10 ร— 2. Which line of code is correct?
    • A. Print(10 * 2)
    • B. Print("10 times 2 = 10 * 2")
    • C. Print("10 times 2 = {10 * 2}")
    • D. Print{"10 times 2"}
  4. After you save changes to your Verse file in VS Code, what must you do in UEFN before the changes show up in your game?
    • A. Drag the device into the level again.
    • B. Go to Verse > Build Verse Code.
    • C. Restart your computer.
    • D. Delete the old device and make a new one.
Answer key
  1. B โ€” In Verse, `Print` sends a text message to the Log โ€” a special screen that shows notes from your code. No paper involved! ๐Ÿ“
  2. B โ€” `OnBegin` is the function UEFN calls the moment the game starts โ€” like a starting pistol at a race. All the code inside it runs right away!
  3. C โ€” You put the math inside curly braces `{ }` inside the quotes. Verse calculates the math and puts the answer right into your message. So `{10 * 2}` becomes `20`!
  4. B โ€” You always need to go to **Verse > Build Verse Code** after saving changes. This tells UEFN to read your latest code. Think of it as pressing 'refresh' so UEFN sees your updates!

Recap

๐Ÿ† Great Work โ€” Let's Recap!

You just wrote and ran your very first Verse program inside a real Fortnite island! ๐ŸŽ‰ You learned that a Verse device is a code-powered object you drop into your level, and that the OnBegin function runs your code the moment the game starts. You used Print to send messages to the Log, and you even used curly braces { } to do live math inside a message. Keep experimenting โ€” every great game developer started exactly where you are right now! ๐ŸŒŸ

Sources

Lesson 3: Variables and Data Types in Verse

Objectives

๐ŸŽฎ What Is a Variable?

Imagine you have a scoreboard in your Fortnite island. Every time a player scores a point, the number goes UP. That number is not stuck at one value โ€” it changes. In Verse, we use a variable to hold a value that can change during the game.

Think of a variable like a labeled box:

๐Ÿง  Variable = a named box that stores one piece of information, and that information can change while the game is running.


๐Ÿ“ฆ Constants โ€” The Box That Never Opens Again

Sometimes you want a value that never changes. Like the number of lives players start with โ€” it's always 3. We call that a constant.

๐Ÿง  Constant = a named box that is sealed shut. You set it once and it stays that way forever.

In Verse, you write a constant with := and you never change it after that first line.


๐Ÿ—‚๏ธ Data Types โ€” What Kind of Stuff Is in the Box?

Not all boxes hold the same kind of stuff. In Verse, every variable has a data type โ€” that just means "what kind of information is stored here?"

Here are the three main types you'll use:

Data Type What It Holds Real-Life Example
int Whole numbers (no decimals) Score: 0, 5, 100
float Numbers with decimals Speed: 1.5, 9.8
string Words or text Player name: "Hero"

๐ŸŽฏ Game tip: Your player's score is an int. A timer that counts down by half-seconds uses a float. A welcome message on screen is a string!


โœ๏ธ How to Write Variables in Verse

Here is the recipe for making a variable in Verse:

Name : type = StartingValue

For a variable that can change, you add the word var in front:

var Name : type = StartingValue

The := symbol means "set this right now." You'll use it to change a var later in your code.

Let's look at real examples:

var Score : int = 0        # A whole-number box that starts at zero
var TimerSeconds : float = 30.0   # A decimal-number box starting at 30
var WelcomeMessage : string = "Welcome to my island!"  # A text box

Notice the # โ€” anything after # is a comment. Comments are notes for YOU. The computer ignores them completely!


๐Ÿ”— How This Connects to Your Island

In UEFN, you build a Verse device โ€” think of it like a special prop that runs your code. When the game starts, your device wakes up and runs its OnBegin function. That's where your variables spring to life!

When a player steps on a trigger, your code can change the variable:

You can then use that score to do things like grant items or activate devices. Your variable is the brain keeping track of everything. ๐Ÿง 

Worked Example

๐Ÿ—๏ธ Building a Score Tracker Device

The scenario: A player steps on a trigger pad. Each time they do, their score goes up by 1. When the score hits 3, a message prints โ€” they WIN! We'll use a trigger_device in UEFN and write a Verse script to track the score.

Step 1: In UEFN, create a new Verse device file. Here's the complete script:

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

# This is our custom device โ€” it tracks a player's score
score_tracker_device := class(creative_device):

    # Hook up a Trigger Device in UEFN's detail panel
    @editable
    TriggerPad : trigger_device = trigger_device{}

    # A variable to hold the current score โ€” starts at zero
    # 'var' means this value CAN change during the game
    var Score : int = 0

    # A constant โ€” the score needed to win never changes
    WinScore : int = 3

    # OnBegin runs automatically when the game starts
    OnBegin<override>()<suspends> : void =
        # Tell the trigger to call our function each time it fires
        TriggerPad.TriggeredEvent.Subscribe(OnPlayerTriggered)

    # This function runs every time a player steps on the trigger
    OnPlayerTriggered(Agent : agent) : void =
        # Add 1 to the Score box
        set Score = Score + 1

        # Print the new score so we can see it in the log
        Print("Score is now: {Score}")

        # Check if the player has reached the winning score
        if (Score >= WinScore):
            Print("๐ŸŽ‰ You Win! Great job!")

๐Ÿ” Walkthrough โ€” Line by Line

Line What it does
using { /Fortnite.com/Devices } Tells Verse we want to use Fortnite devices like triggers
score_tracker_device := class(creative_device): Creates our custom device
@editable Makes TriggerPad appear in the UEFN editor so you can drag-and-drop a trigger onto it
var Score : int = 0 Makes a changeable box called Score that holds whole numbers, starting at 0
WinScore : int = 3 A constant โ€” no var, so it can never be changed by accident
OnBegin<override>()<suspends> : void = Runs once when the game starts
TriggerPad.TriggeredEvent.Subscribe(OnPlayerTriggered) Listens for the trigger and calls our function when it fires
set Score = Score + 1 Opens the Score box and puts in the old value plus one
Print("Score is now: {Score}") Shows the score in the Output Log โ€” great for testing!
if (Score >= WinScore): Checks if score is 3 or more
Print("๐ŸŽ‰ You Win!") Celebrates the win!

โœ… Try it: In UEFN, place a Trigger Device on your island. Assign it to TriggerPad in the device details. Hit Launch Session and walk over the trigger three times. Watch the Output Log โ€” you should see the score climb to 3 and then see the win message!

Try It Yourself

๐Ÿ› ๏ธ Your Turn โ€” Add a Lives Counter!

You just made a score tracker. Now let's add a lives system!

Your challenge:

  1. Add a new var variable called Lives of type int. Start it at 3.
  2. Add a second @editable trigger called DangerZone of type trigger_device.
  3. Subscribe to DangerZone.TriggeredEvent with a new function called OnDangerTriggered.
  4. Inside OnDangerTriggered, subtract 1 from Lives using set Lives = Lives - 1.
  5. Print the new lives count with Print("Lives left: {Lives}").
  6. Add an if check โ€” if Lives <= 0, print "๐Ÿ’€ Game Over!".

In UEFN: Place a second Trigger Device somewhere dangerous on your island (like lava or a trap area). Assign it to DangerZone. Play the island and walk into the danger zone three times!


๐Ÿ’ก Hint: Subtracting in Verse looks just like adding, but with a - sign instead of +. The if check for lives running out looks just like the win check in the example โ€” just change the variable name and the message!

๐ŸŒŸ Bonus challenge: Can you add a string variable called PlayerStatus that starts as "Alive" and changes to "Defeated" when lives hit zero?

Quiz

  1. What is a variable in Verse?
    • A. A value that is set once and never changes
    • B. A named box that stores information which can change during the game
    • C. A special Fortnite device you place on your island
    • D. A comment that the computer ignores
  2. A player's score in a game is 10. What is the best data type to store it?
    • A. string, because scores are important words
    • B. float, because all numbers need decimals
    • C. int, because a score is a whole number with no decimal
    • D. var, because it can change
  3. Which line of Verse code correctly creates a variable for a player's speed that starts at 5.5?
    • A. Speed : int = 5.5
    • B. var Speed : float = 5.5
    • C. var Speed : string = 5.5
    • D. Speed : var = 5.5
  4. In the score tracker example, why is WinScore written WITHOUT the word var?
    • A. It was a mistake โ€” all variables need var
    • B. Because int variables never need var
    • C. Because WinScore is a constant โ€” the winning number never changes during the game
    • D. Because string types don't use var
Answer key
  1. B โ€” A variable is like a labeled box โ€” you can change what's inside it while the game is running. That's what makes it different from a constant!
  2. C โ€” A score like 10 is a whole number โ€” no decimal needed! That makes int the perfect type. (var just means it CAN change โ€” it's not a data type by itself.)
  3. B โ€” 5.5 has a decimal, so the type should be float. We need var because speed can change during the game. The correct recipe is: var Name : type = value.
  4. C โ€” WinScore is a constant โ€” the score you need to win stays the same the whole game. Leaving out var means Verse won't let you accidentally change it later. Smart move!

Recap

๐ŸŒŸ Great Work โ€” Here's What You Learned!

A variable is a named box that stores information that can change during your game โ€” like a score that goes up when a player does something. A constant is a sealed box set once and never changed. Every variable has a data type: int for whole numbers, float for decimal numbers, and string for text. You used all of these inside a real Verse device that tracked a player's score on a Fortnite island โ€” and that's genuinely awesome programming! ๐ŸŽ‰

Sources

Lesson 4: Writing and Using Functions

Objectives

๐ŸŽฎ Why Do We Need Functions?

Imagine you're building a Fortnite island. Every time a player steps on a pressure plate, you want to:

  1. Add 10 points to their score.
  2. Play a sound.
  3. Print a message.

What if there are 20 pressure plates? You'd have to write those same 3 steps 20 times. That's exhausting! ๐Ÿ˜ฉ

A function fixes this. Think of a function like a vending machine. You press a button (call the function), and the machine does all the work for you every time. You only have to set it up once.


๐Ÿงฉ What Is a Function?

A function is a named block of code that does one job. You write it once, then call it (run it) as many times as you want.

Think of it like a recipe card. The card says "make a sandwich." You follow the steps. Next time you're hungry, you grab the same card โ€” you don't write a new recipe!


๐Ÿ“ฆ What Is a Parameter?

A parameter is information you hand to a function so it can do its job. It's like telling the vending machine which snack you want. Different input โ†’ different result!

For example, imagine a function called GivePoints. You could tell it to give 10 points one time, and 50 points another time. Same function, different number!

In Verse, you write a parameter like this inside the parentheses ():

Points : int

๐ŸŽ What Is a Return Value?

Sometimes you want a function to give something back after it runs. That's called a return value.

Imagine you ask a friend, "How many lives do I have left?" Your friend counts and tells you back the answer. That answer is the return value!

In Verse, you write : int (or another type) after the parentheses to say "this function will hand back a number."

If a function doesn't need to give anything back, you just leave that part out (or use : void).


๐Ÿ› ๏ธ The Parts of a Function in Verse

Here's what a function looks like, piece by piece:

FunctionName(ParameterName : type) : returnType =
    # Your code goes here, indented

๐Ÿ“ฃ Calling a Function

Calling a function means telling it to run. You just write its name and pass in any info it needs:

GivePoints(10)

That's it! The vending machine does its job. ๐ŸŽ‰


๐Ÿ๏ธ Connecting to Your Island

In UEFN, your Verse code lives inside a Verse Device โ€” a special invisible gadget you place on your island. When something happens in the game (like a player steps on a Trigger device), your device can run a function.

Here's the big picture of how it works:

  1. You place a Trigger device on your island in UEFN.
  2. Your Verse device has a reference to that trigger.
  3. When the trigger fires, Verse calls your function automatically.
  4. Your function runs its steps โ€” like printing a score message!

This is the magic of functions: the island event calls your function, and your function does all the hard work! ๐Ÿš€

Worked Example

๐Ÿ”จ Worked Example: A Score Announcer Device

The scenario: A player walks into a trigger zone on your island. Your Verse device runs a function that calculates their bonus score and prints a hype message. Let's build it!


Step 1 โ€” Set up in UEFN:


Step 2 โ€” The Verse code:

using { /Script/VerseRuntime }
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Native }

# This is our Verse Device class.
score_announcer := class(creative_device):

    # We hook up a Trigger device here in the UEFN editor.
    @editable
    MyTrigger : trigger_device = trigger_device{}

    # OnBegin runs automatically when the game starts.
    OnBegin<override>()<suspends> : void =
        # Tell the trigger: when someone enters it, call OnPlayerTriggered.
        MyTrigger.TriggeredEvent.Subscribe(OnPlayerTriggered)

    # This function runs when the trigger fires.
    # Agent is the player who stepped on the trigger.
    OnPlayerTriggered(Agent : agent) : void =
        # Calculate the bonus using our helper function.
        Bonus := CalculateBonus(10)
        # Print the result so we can see it while playtesting.
        Print("Bonus points earned: {Bonus}")

    # ------------------------------------------
    # Our custom function!
    # It takes one parameter: BasePoints (a whole number).
    # It returns a whole number (the bonus score).
    # ------------------------------------------
    CalculateBonus(BasePoints : int) : int =
        # Double the base points and give that back.
        return BasePoints * 2

๐Ÿ“– Walkthrough โ€” What Each Part Does

Line / Block Plain-English Meaning
score_announcer := class(creative_device) Creates our custom device. Think of it as naming our vending machine.
@editable / MyTrigger Lets us plug in a real Trigger device from the UEFN editor โ€” like connecting a wire.
OnBegin<override>()<suspends> : void This special function runs the moment the game starts. void means it gives nothing back.
MyTrigger.TriggeredEvent.Subscribe(OnPlayerTriggered) "Hey Trigger, when you fire, call OnPlayerTriggered!" Like setting up a doorbell.
OnPlayerTriggered(Agent : agent) : void Runs when a player steps on the trigger. Agent is that player.
CalculateBonus(10) Calling our custom function and handing it the number 10.
CalculateBonus(BasePoints : int) : int Defining our custom function. It takes a number in and gives a number back.
return BasePoints * 2 Doubles the number and hands it back to whoever called the function.

๐ŸŽฎ Try It!

  1. Compile and drag both devices onto your island.
  2. In the UEFN editor, click your score_announcer device and set MyTrigger to point at your Trigger device.
  3. Hit Launch Session and walk into the trigger zone.
  4. Look at the on-screen log โ€” you should see "Bonus points earned: 20"!

You just wrote and called your very own function. You're a real programmer now! ๐Ÿ†

Try It Yourself

๐Ÿ•น๏ธ Your Turn: The Multiplier Machine

You did awesome with CalculateBonus! Now it's time to level up. ๐Ÿ’ช

Your challenge:

Add a second custom function called CalculateTripleBonus to the score_announcer device. This function should:

  1. Take one parameter: a whole number called BasePoints.
  2. Multiply BasePoints by 3 (triple it!).
  3. Return the result.

Then, inside OnPlayerTriggered, call your new function with the number 15 and print the result like this:

Triple bonus: 45

๐Ÿชœ Hints (if you need them!):

Bonus challenge ๐ŸŒŸ: Can you call CalculateBonus AND CalculateTripleBonus in the same OnPlayerTriggered function and print both results?

Go for it โ€” you've totally got this! ๐ŸŽ‰

Quiz

  1. What is a function in programming?
    • A. A type of Fortnite weapon.
    • B. A named block of code that does one job and can be run many times.
    • C. A variable that stores a player's score.
    • D. A device you place on your island.
  2. What is a parameter?
    • A. The name of a Verse device.
    • B. A special button in UEFN.
    • C. Information you hand into a function so it can do its job.
    • D. The return value of a function.
  3. Look at this code: CalculateBonus(BasePoints : int) : int. What does the SECOND `: int` mean?
    • A. The function needs two numbers.
    • B. The function will give back a whole number when it's done.
    • C. The parameter must be named 'int'.
    • D. The function runs twice.
  4. You wrote a function called GiveShield. How do you call it and hand it the number 50?
    • A. function GiveShield(50)
    • B. GiveShield : 50
    • C. GiveShield(50)
    • D. call GiveShield with 50
Answer key
  1. B โ€” A function is like a recipe โ€” you write it once and can "use" it (call it) as many times as you need. It's a named block of code that does one job!
  2. C โ€” A parameter is like telling the vending machine which snack you want. It's the information you give a function so it knows what to work with.
  3. B โ€” The return type (the second ': int') tells Verse what kind of thing the function will hand back. Here it means the function gives back a whole number (int).
  4. C โ€” In Verse, you call a function by writing its name followed by parentheses with the value inside โ€” just like GiveShield(50). Simple and clean!

Recap

๐ŸŒŸ Great Work โ€” Here's What You Learned!

A function is a named block of code you write once and can run (call) as many times as you need โ€” like a vending machine you set up once. You can hand a function information using parameters, and a function can return (give back) a result when it's done. In your Fortnite island, functions connect to real game moments โ€” like a player stepping on a trigger โ€” so your island actually does something when players play it. Keep building, keep creating, you're doing amazing! ๐Ÿš€

Sources

Lesson 5: Control Flow: If Statements and Loops

Objectives

๐ŸŽฎ What Is Control Flow?

Imagine you are playing a board game. You roll the dice. If you land on a red square, you lose a turn. Otherwise, you move ahead. The rules of the board game control what happens next.

In coding, control flow means: the order in which your code runs, and which parts it chooses to run. You are the rule-maker. You tell the computer, "Do THIS if something is true. Do THAT if it isn't."


๐Ÿšฆ If Statements โ€” Your Game's Referee

An if statement is like a referee on your island. It watches what is happening. Then it makes a call.

Think of it like this:

If the player's score is 10 or more โ†’ open the treasure chest! Else โ†’ keep the chest locked.

The word if starts the check. The word else handles everything that is NOT true.

In Verse, it looks like this:

if (Score >= 10):
    # Do this when score is high enough
else:
    # Do this when score is too low

๐Ÿ’ก New Word โ€” Condition: A condition is a question that is either TRUE or FALSE. "Is it raining?" is a condition. "Is the player's score above 5?" is also a condition!


๐Ÿ” Loops โ€” Your Island's Copy Machine

What if you wanted to give every player on your island 3 potions, one at a time? You could write the same line of code 3 times. But what if you wanted to do it 100 times? Writing 100 lines is no fun!

A loop is like a copy machine for your code. It runs the same instructions over and over until you say stop.

๐Ÿ’ก New Word โ€” Loop: A loop repeats a block of code. It's like pressing "replay" on a song, but for instructions.

Verse has a simple counting loop called a for loop. You tell it how many times to repeat. Here is the idea:

for (Index := 0..2):
    # This runs 3 times (0, 1, 2)

That 0..2 means "count from 0 up to and including 2." That is 3 counts total. Think of it as laps around a track: lap 0, lap 1, lap 2 โ€” done!

๐Ÿƒ Analogy: A for loop is like a coach yelling "Run 3 laps!" Your player runs one lap, then another, then another โ€” and stops.


๐Ÿงฉ Putting It Together on Your Island

Let's say you are building a Score Challenge island. Here is the plan:

You use an if statement for the score check. You use a loop for the weapon hand-out. Together, they make your island smart and fun!


๐Ÿ—‚๏ธ The Shape of Verse Code

Two things to always remember about Verse:

  1. Indentation matters. The code inside an if statement or loop must be indented (pushed in with spaces). This is how Verse knows which lines belong together.
  2. Colons start a block. After if(...) and for(...), you put a colon : and then indent the next lines.

Think of indentation like putting toys inside a box. The toys (code lines) belong to the box (if or loop) only if they are inside it.

Worked Example

๐Ÿ—๏ธ Building a Score Reward System

The island plan:

When a player walks into the trigger, the code checks their score. If they earned 5 or more points, the Item Granter fires! The loop at the start hands out 3 starting items automatically.

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

# This is our Verse device class โ€” it lives on the island
score_reward_device := class(creative_device):

    # Plug these in from the UEFN editor by selecting your devices
    @editable
    GranterDevice : item_granter_device = item_granter_device{}

    @editable
    TriggerDevice : trigger_device = trigger_device{}

    # OnBegin runs once when the game starts
    OnBegin<override>()<suspends> : void =
        # Subscribe to the trigger โ€” when a player steps on it, call OnTriggered
        TriggerDevice.TriggeredEvent.Subscribe(OnTriggered)

    # This function runs every time a player hits the trigger
    OnTriggered(Agent : ?agent) : void =
        # Try to get the player's score from the score manager
        # We track score with a simple variable here for the example
        var PlayerScore : int = 6  # Pretend the player has 6 points

        # ---- IF STATEMENT ----
        # Check: does the player have 5 or more points?
        if (PlayerScore >= 5, ActualAgent := Agent?):
            # YES โ€” grant them a reward item!
            GranterDevice.GrantItem(ActualAgent)
            Print("Great job! You earned a reward!")  # Shows in the log
        else:
            # NO โ€” encourage them to keep going
            Print("Keep collecting points โ€” you need 5!")```

### ๐Ÿ” Walkthrough โ€” Line by Line

| Code Part | What It Does |
|---|---|
| `score_reward_device := class(creative_device)` | Creates our island device โ€” like building a new LEGO piece |
| `@editable` | Lets us plug in real devices from the UEFN editor |
| `OnBegin<override>()<suspends> : void` | Runs once when the game starts |
| `TriggerDevice.TriggeredEvent.Subscribe(OnTriggered)` | Tells the trigger: "Call OnTriggered when someone steps on you" |
| `var PlayerScore : int = 6` | A variable storing the player's score (6 for this example) |
| `if (PlayerScore >= 5):` | The BIG QUESTION โ€” is the score 5 or more? |
| `GranterDevice.GrantItem(Agent)` | Gives the item to the player who triggered it |
| `else:` | Handles the "not enough points" case |
| `Print(...)` | Sends a message to the output log so you can see what happened |

> โœ… **Try it!** In UEFN, place a Trigger Device and an Item Granter Device. Connect them to your Verse device using the `@editable` slots. Change `PlayerScore` to 3 and play โ€” you should see the "keep collecting" message instead!

---

### ๐Ÿ” Bonus: Adding a Loop for Warm-Up Items

Want to grant 3 items when the game starts? Add this loop inside `OnBegin`, **before** the Subscribe line:

```verse
# Loop 3 times (Index goes 0, 1, 2)
for (Index := 0..2):
    # Each loop gives ALL agents a starting item
    # (In a real game, you'd loop through players โ€” this shows the loop shape)
    Print("Granting warm-up item number {Index}")
    # GranterDevice.GrantItem(SomeAgent)  # Uncomment when you have a real agent

๐ŸŽ‰ What just happened? The loop ran 3 times on its own. You wrote the Print line once but the computer did it 3 times. That's the magic of loops!

Try It Yourself

๐Ÿ› ๏ธ Your Turn: The Double Score Challenge!

You are going to upgrade the Score Reward System. Here is your challenge:

Goal: Change the if statement so there are THREE outcomes instead of two:

  1. If the player's score is 10 or more โ†’ print "LEGENDARY reward unlocked!"
  2. If the player's score is 5 or more (but less than 10) โ†’ print "Nice! Here's a common item!"
  3. If the score is below 5 โ†’ print "Keep going, you can do it!"

In Verse, you can chain conditions like this using else if:

if (Score >= 10):
    # first case
else if (Score >= 5):
    # second case
else:
    # third case

Steps:

  1. Open your Verse file from the worked example above.
  2. Change var PlayerScore : int = 6 to different values (like 11, 7, and 3) to test each branch.
  3. Update the if/else block to have all three cases using else if.
  4. Bonus ๐ŸŒŸ: Add a loop that counts from 1 to 5 and prints "Counting: {Index}" each time. Put it inside OnBegin.

๐Ÿ’ก Hint: Remember to indent your code inside each if, else if, and else block. Verse is strict about indentation โ€” it's like making sure your toys are inside the box, not next to it!

๐Ÿ’ช You've got this! Try changing the score value and see how different branches run. That's real debugging โ€” just like a game developer does!

Quiz

  1. What does an if statement do in Verse?
    • A. It runs the same code over and over forever
    • B. It checks a true/false condition and runs different code based on the answer
    • C. It stores a number like a player's score
    • D. It creates a new device on the island
  2. In this Verse code: `for (Index := 0..2):` โ€” how many times does the loop run?
    • A. 2 times
    • B. 0 times
    • C. 3 times
    • D. 4 times
  3. What happens to the code inside an `else` block?
    • A. It always runs no matter what
    • B. It runs only when the if condition is TRUE
    • C. It runs only when the if condition is FALSE
    • D. It runs before the if statement checks anything
  4. Why does indentation matter so much in Verse?
    • A. It makes the code look pretty but doesn't change how it works
    • B. It tells Verse which lines of code belong inside an if statement or loop
    • C. It makes the game run faster
    • D. It is only needed for Print statements
Answer key
  1. B โ€” An if statement checks a condition โ€” a yes or no question โ€” and runs different code depending on whether the answer is true or false. It's like a referee making a call!
  2. C โ€” The range 0..2 counts 0, 1, and 2 โ€” that's 3 numbers, so the loop runs 3 times. Think of it like 3 laps around a track!
  3. C โ€” The else block is the backup plan โ€” it only runs when the if condition is false. Like: IF it's raining, grab an umbrella. ELSE, wear sunglasses!
  4. B โ€” In Verse, indentation tells the computer which lines belong inside a block of code (like an if or a loop). If your indentation is wrong, the code won't work right โ€” just like toys falling out of a box if you don't put them inside it!

Recap

๐ŸŒŸ Great Work โ€” Here's What You Learned!

Control flow means deciding which code runs and when โ€” just like the rules of a board game. An if statement checks a true/false condition and picks a path, like a referee making a call on your island. A loop repeats code automatically so you don't have to write the same lines over and over. Put them together and your Fortnite island can react to players, check scores, and hand out rewards like a real game designer made it! ๐ŸŽฎ

Sources

Lesson 6: Create Your First Verse Device Script

Objectives

๐ŸŽฎ What Is a Verse Device?

Imagine a remote control car. The car itself sits on the floor of your room โ€” that's like your Fortnite island. The circuit board inside the car is the device. The instructions you program into it tell the car what to do: go forward, turn left, honk!

A Verse device works the same way. It's a little invisible gadget you place on your island. Your Verse code is the instructions inside it. When the game starts, the device follows your instructions and makes things happen!


๐Ÿ› ๏ธ Step 1 โ€” Create a New Verse Device File

First, you need to make the file where you'll write your code. Think of this like getting a blank piece of paper before you draw.

Here's how:

  1. Open your project in UEFN (Unreal Editor for Fortnite).
  2. In the top menu bar, click Verse, then click Verse Explorer. This is like a file cabinet for all your Verse scripts.
  3. In Verse Explorer, right-click your project name. Choose Add new Verse file to project.
  4. A window pops up. Click Verse Device as your template. A template is a starter design โ€” like a cookie cutter that already has the basic shape.
  5. In the Device Name box, type score_tracker_device. Then click Create.
  6. Double-click your new file in Verse Explorer. It opens in Visual Studio Code โ€” that's your coding notebook!

๐Ÿงฑ Step 2 โ€” Understand the Starter Code

When UEFN creates your device file, it gives you some starter code. Here's what the important parts mean:


๐Ÿ”ข Step 3 โ€” Variables: Boxes That Hold Information

A variable is like a labeled box. You put something inside, and you can change what's in it later.

For example:

In Verse, you create a variable like this:

var Score : int = 0

โš™๏ธ Step 4 โ€” Functions: Named Sets of Instructions

A function is like a recipe. You write it once, give it a name, and you can use it over and over.

Imagine a recipe called "Make Lemonade." Every time you follow it, you get lemonade! A function called AddPoint could say: every time you run it, add 1 to the score.


๐Ÿ”€ Step 5 โ€” Control Flow: Making Decisions

Control flow means your code can make choices. Think of it like a Choose-Your-Own-Adventure book.

If something is true, do this. Else (otherwise), do that.

if (Score >= 3):
    Print("You win! ๐ŸŽ‰")
else:
    Print("Keep going!")

๐Ÿ“ฆ Step 6 โ€” Compile and Place Your Device

Compiling means turning your human-readable code into something UEFN can actually run. It's like a translator turning English into Robot Language.

  1. In the top menu, click Verse > Build Verse Code.
  2. Wait a moment. Your device now appears in the Content Browser under CreativeDevices.
  3. Drag and drop your device onto your island โ€” just like placing any other object!
  4. Click Launch Session in the toolbar to playtest. Hit Start Game and watch your code run! ๐Ÿš€

Worked Example

๐Ÿ† Worked Example: A Score-Tracking Device

The goal: Make a device that tracks a player's score. When the game starts, it gives the player points one at a time and announces when they win.

Place this code inside your device file in Visual Studio Code:

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

# This tells UEFN that our script is a real device for the island
score_tracker_device := class(creative_device):

    # A variable โ€” like a labeled box โ€” to hold the score.
    # "var" means we can change it later. It starts at 0.
    var Score : int = 0

    # OnBegin runs automatically the moment the game starts.
    # Think of it as the starting pistol for your code!
    OnBegin<override>()<suspends> : void =
        Print("Game started! Score = 0")  # Announce the start

        # Call our custom function to add a point
        AddPoint()
        AddPoint()
        AddPoint()  # Add three points, one at a time

    # This is our custom function โ€” a recipe called "AddPoint"
    AddPoint() : void =
        set Score = Score + 1  # Open the box, add 1, put it back
        Print("Score is now: {Score}")  # Show the new score

        # Control flow: check if the player has won yet
        if (Score >= 3):
            Print("YOU WIN! Amazing job! ๐ŸŽ‰")  # Score is 3 or more
        else:
            Print("Keep it up! Almost there!")  # Score is less than 3

๐Ÿ“– Walkthrough

Line What it does
score_tracker_device := class(creative_device) Says "this is a device that goes on the island"
var Score : int = 0 Creates a number box called Score, starting at 0
OnBegin<override>()<suspends> : void = This runs the moment the game starts
AddPoint() Runs our recipe/function to add one point
set Score = Score + 1 Opens the Score box and adds 1
if (Score >= 3) Asks: is Score 3 or bigger?
Print(...) Shows a message in the game log โ€” great for testing!

๐ŸŽฎ What You'll See

When you playtest, check the Output Log in UEFN. You'll see messages like:

Game started! Score = 0
Score is now: 1
Keep it up! Almost there!
Score is now: 2
Keep it up! Almost there!
Score is now: 3
YOU WIN! Amazing job! ๐ŸŽ‰

Your Verse code is running live inside your Fortnite island! How cool is that? ๐ŸŒŸ

Try It Yourself

๐ŸŽฏ Your Turn: Build a Countdown Device!

You just saw a score go up. Now try making it go down โ€” like a countdown!

Your mission:

  1. Create a new Verse device called countdown_device.
  2. Add a variable called TimeLeft that starts at 5.
  3. Write a function called Tick that subtracts 1 from TimeLeft each time it runs. (Hint: subtraction uses the - symbol!)
  4. Call Tick five times inside OnBegin.
  5. Use an if/else to check: if TimeLeft <= 0, print "Blast off! ๐Ÿš€". Otherwise, print "Counting down: {TimeLeft}".
  6. Compile your code (Verse > Build Verse Code), drag it onto your island, and playtest!

๐Ÿ”‘ Hints:

Bonus challenge ๐ŸŒŸ: Can you change the win condition so it prints a special message when TimeLeft reaches exactly 0?

Quiz

  1. What does 'compiling' your Verse code do?
    • A. It deletes your code so you can start over.
    • B. It turns your code into something UEFN can actually run on your island.
    • C. It automatically adds your device to the level for you.
    • D. It sends your island to all your friends.
  2. In Verse, what does the keyword 'var' tell the computer?
    • A. This value is a secret and will never be shown.
    • B. This is a function that runs automatically.
    • C. This is a box that can hold a value AND that value can change later.
    • D. This line of code should be skipped.
  3. When does the 'OnBegin' function run in a Verse device?
    • A. Every single second while the game is running.
    • B. Only when a player walks into a trigger zone.
    • C. Automatically the moment the game starts.
    • D. Only when you manually call it from Verse Explorer.
  4. What happens in Verse when an 'if' condition is FALSE?
    • A. The whole program stops and crashes.
    • B. The 'if' block is skipped, and the 'else' block runs instead.
    • C. The 'if' block runs twice to make up for it.
    • D. Verse ignores both the 'if' and 'else' blocks.
Answer key
  1. B โ€” Compiling is like a translator. It takes the code you wrote and turns it into instructions the game engine can understand and run. You must compile before you can use your device on your island!
  2. C โ€” 'var' stands for variable โ€” think of it as a labeled box. The 'var' keyword tells Verse that the value inside this box is allowed to change during the game, like a score that goes up each time a player scores a point.
  3. C โ€” OnBegin is like the starting pistol at a race โ€” BANG, the game begins, and OnBegin fires immediately! It's the perfect place to set things up at the very start of your island game.
  4. B โ€” Control flow is like a fork in the road. If the condition is true, you go left (the 'if' block). If it's false, you go right (the 'else' block). One path always runs โ€” they just take turns depending on the answer!

Recap

๐ŸŒŸ Great Work โ€” Here's What You Learned!

Today you built your very first custom Verse device from scratch. You learned that a variable is like a labeled box that can hold changing information (like a score), and a function is a reusable recipe of instructions you can call by name. You used control flow (if/else) to make your device make smart decisions. Finally, you compiled your code and dropped your device onto your real Fortnite island โ€” which means YOU just made something that runs live inside a game. That is seriously impressive! ๐ŸŽ‰

Sources

Generated by Verse Island on 2026-06-21.