If you're coming from C++, Blueprint, or Python, Verse is going to trip you up at first. Not because it's harder—because it thinks about control flow in a completely different way.
Most languages care about true and false. Verse cares about success and failure. That single shift changes how you write conditionals, loops, and even simple array lookups. Once it clicks, though, you'll find it's actually a cleaner way to handle the "what if this doesn't work" problem that every game script eventually runs into.
Let's break down how it actually works.
Conditionals Aren't Just Yes/No Anymore
Here's the first surprise: if in Verse isn't just a branch—it's an expression. That means it can hand you back a value, not just decide which path to run.
IsGameOver : logic = false
if (IsGameOver?):
Print("Game Over!")
else:
Print("Keep Playing!")
Notice that ? sitting after IsGameOver. You can't skip it. Verse won't just look at a logic variable and assume you want to test it—you have to explicitly ask it to succeed. Forget the ? and your code won't compile the way you expect.
Because if returns a value, you can skip the whole "declare a variable, then set it inside a branch" dance:
Score : int = 120
ScoreStatus := if (Score > 100) then "High Score" else "Low Score"
One line. No temp variable. No mutation. That's the kind of thing that feels awkward the first time you write it and then becomes your default habit within a week.
When You Need More Than Two Branches
Stacking if-else chains gets ugly fast, especially once you're past three or four options. That's where case comes in—it's Verse's answer to switch statements, and it reads a lot more naturally.
ItemCount : int = 3
case (ItemCount):
1 => Print("You have one item.")
2 => Print("You have two items.")
3 => Print("You have three items!")
_ => Print("You have a lot of items.")
That underscore at the bottom isn't decoration—it's your catch-all. Leave it out and you risk a case with no matching branch, which is exactly the kind of silent bug that eats an afternoon.
Loops: Two Tools, Two Very Different Jobs
Verse gives you loop and for, and they're not interchangeable. Picking the wrong one is a common rookie mistake.
loop — For When You Don't Know How Many Times
loop just keeps going. Forever. Unless you tell it to stop.
var Counter : int = 0
loop:
set Counter += 1
Print("Loop count: {Counter}")
if (Counter >= 5):
break
That break isn't optional here—it's load-bearing. Without it, this loop never ends. Use loop when the exit condition depends on something happening during execution, not something you can calculate up front.
for — For When You're Iterating Over Something
for is where Verse really shows off. It doesn't just walk through arrays and ranges—it filters as it goes, right inside the loop header.
for (Index := 1..5):
Print("Current number: {Index}")
Straightforward enough. But here's the part that'll save you real time:
Numbers : []int = array{1, 2, 3, 4, 5, 6}
for (Num : Numbers, Num % 2 == 0):
Print("Found an even number: {Num}")
That second clause—Num % 2 == 0—is a built-in filter. If it fails on a given item, Verse doesn't crash or throw an error. It just quietly skips to the next one. No continue keyword needed, no nested if inside your loop body cluttering things up.
The Real Heart of Verse: Failure Contexts
This is the part that actually separates Verse from everything else you've used, so it's worth slowing down for.
Some operations in Verse are labeled decides—meaning they're allowed to fail instead of crashing your program. Pulling an item from an array by index is a perfect example. What happens if the index is out of range? In most languages, that's a runtime error, maybe a crash, maybe an ugly exception you have to catch.
In Verse, it just... fails gracefully. But only if you've wrapped it in a failure context—somewhere the language knows how to handle a fail state, like an if condition or a for filter.
Inventory : []string = array{"Sword", "Shield", "Potion"}
if (Item := Inventory[3]):
Print("Found item: {Item}")
else:
Print("Index out of bounds! The operation safely failed instead of crashing.")
Index 3 doesn't exist in a three-item array (remember, indexing starts at 0). Instead of blowing up, that access simply fails, and control drops into the else block. No try-catch. No exception handling boilerplate. Just a clean, built-in escape hatch.
This is the mental shift you need to make: in Verse, failure isn't an error. It's a normal, expected outcome that you design around.
Putting It All Together
Here's a script that combines everything above—loop, filtered iteration, and safe fallible indexing—into one working example:
using { /Verse.org/Simulation }
RunControlFlowDemo() : void =
Scores : []int = array{45, 110, 85, 150, 30}
Print("--- Finding High Scores ---")
for (Score : Scores, Score > 100):
Print("Passed Milestone: {Score}")
Print("--- Safe Array Processing ---")
var Index : int = 0
loop:
if (CurrentScore := Scores[Index]):
Print("Processing score at index {Index}: {CurrentScore}")
set Index += 1
else:
Print("Reached the end of the array.")
break
Look closely at that second block. The loop doesn't check Index < Scores.Length the way you might in another language. It just keeps trying to read the next index—and when that read fails (because you've walked off the end of the array), the else branch catches it and breaks the loop. The failure itself is your exit condition.
That's Verse in a nutshell. Instead of bolting error-handling onto your control flow after the fact, failure is baked into the syntax from the start. It takes some rewiring of your instincts if you're used to true/false logic—but once you're fluent in it, you'll probably miss it when you go back to anything else.