Verse Language : Understanding Expressions

VERSE LANGUAGE : UNDERSTANDING EXPRESSIONS
Expressions (which are combinations of values and functions) are the smallest units of code. Since everything in Verse is an expression, understanding this is of the utmost importance!
In my last article: How Rules and Events Work Together to Create Actions, I briefly discussed how expressions work within Verse when I spoke about conditionals. If you missed that article, no worries, you can catch it here:
HOW RULES AND EVENTS WORK TOGETHER TO CREATE ACTIONS
When using Verse you will find that expressions are used 100% of the time. That is because everything in Verse evaluates to a value! A value is information your program needs to operate. Examples of values are numbers or text. In the UEFN Documentation you will find an excellent example of how Verse evaluates to a value when using the if, else expression.

EXPRESSION COMMUNITY EXAMPLES
And here are some more examples of snippets from the Unreal Engine Development Community!
DAY/NIGHT CYCLE SCRIPT | By Blue Clairy View entire script: https://dev.epicgames.com/community/snippets/Yxr/fortnite-basic-day-night-loop

NUMBER GUESSER GAME | By Snownymous View entire script: https://dev.epicgames.com/community/snippets/EBg/fortnite-number-guesser-game

CAN YOU FIND MORE EXPRESSIONS?
Take a look at more community-submitted Verse codes and see if you can discover more expressions! If you find some, take a screenshot and ping me @[PRO] Dragon in the FCHQ Discord! As you browse through I'm sure you will find plenty because expressions are everything in Verse!
View Community Snippets https://dev.epicgames.com/community/fortnite/snippets
EXPRESSIONS ARE VERSATILE!
Expressions can also be versatile and allow an array of values, by using loops! A loop repeats expressions that is within a code block. Let's look at this example:
(Source - Epic Games: https://dev.epicgames.com/documentation/en-us/uefn/verse-glossary#failurecontext)
Let's read it out - within the loop you have a code block that evaluates time and if that time passes then a value (or event) will take place. So let's put this into terms here!
When one second passes, the platform will disappear. When another second passes, the platform will show! Since these expressions are within a loop expression block, they will repeat forever unless you exit the loop!
EXPRESSIONS CAN BE SET TO ANTICIPATE A FAIL
There are times when expressions fail or return no value. These are called Failable expressions. Expressions such as these can only be used when you anticipate a fail since the failure context determines what happens when the expression fails. A failure context allows you to execute expressions that could fail and that context determines what happens once the expression goes wrong.
Read more about Failable Expressions here: https://dev.epicgames.com/documentation/en-us/uefn/verse-glossary#failableexpression
LIST OF ALL EXPRESSIONS IN VERSE
Now that you know all there is to know about expressions and their importance when coding with Verse! Here is a list of all the expressions you will encounter in Verse!
• Literals
• Function Calls
• Comparison
• Assignment
• Math
• Decision
• Query
• Class and Struct Instantiation
• Control Flow
• Array
• Tuple
• Map
• Option
• Range
Get a full breakdown of what each of these expressions mean by visiting https://dev.epicgames.com/documentation/en-us/uefn/expressions-in-verse

.
Comments
You must be logged in to comment.