Skip to content

Variables_Condition_Statements

Jack Brett edited this page May 9, 2024 · 9 revisions

Variables

LUTE defines variables that will live on Flow Engines. Rather than forcing designers to use code, we have defined some common variables that when used allow Nodes, Orders and Engines to share data and create more complex experiences.

Define: Variable

Simply put, a variable is named location to store data. Variables exist on the Flow Engine and are used to keep track of progress, items, choices and more related to the player. They are often used to pass data from one order to another or be used when checking conditions.

Variables do not automatically save and restore between play but the Save Variable mechanisms can be used to save and load variables from/to disk.

Typically when using conditional statements, we use a variable and an operation (such as equals or does not equal). This evaluation is typical when using common variable types (such as integers and strings) and will compare the provided input with the variable in question. However, certain variables (such as inventory items and locations) will use more complex evaluation methods; whilst it is not imperative to understand this at a high level, if one wishes to create new variables and custom evaluation methods then they should seek to understand this further.

The Variable List

Variables can be created within the Flow Engine Inspector and become visible in the Flow Engine Inspector and Window:

variableAdding

windowVars engineVars

Each Variable needs a name which is how they are presented when used in ORders and drop-downs. You can set values of variables directly in the varibale list for most variable types. A common example might be an integer variable called 'Lives' which may initially be set to start at 3.

Define: Variable Types

As we find in C#, Variables in LUTE declare the type of data they are going to contain.

engineVars

Simple experiences will likely use booleans, integers and strings along with more complex types such as Locations.

Define: Variable Scope

Much like we would define the scope of a variable in C#, we can do the same in LUTE (currently allowing private, public and global).

variableScope

  • Private is not available to other Engines which ensures that the variable is only relevant to the Engine it has been created on.
  • Public indicates that the variable can be found and is intended to be used or modified by other Engines. Those other Engines will need to be able to directly access the Engine the variable is declared on to modify it.
  • Global allows for sharing state among all Engines, without direct access to other Engines. It also ensures that the value of the variable can exist and outlive the Engine that it was declared by.

When looking for variables, the Engine will first look for variables on itself and then for any public variables contained on other active Engines in the scene.

Condition Statements

A core aspect of using variables will be setting up condition statements with them. The most basic example that can be used would be an 'if statement' which uses:

  • An operation (equals, greater than etc.)
  • A variable (integer, float, string etc.)

To add an if statement as an order, select a Node and then add a new Order: Logic>If. Select the new Order and observe the inspector.

[show the if order being chosen]

The If Order uses a list of conditions to avoid having to create unique Orders for every statement required. The first property to determine is the 'Any or All Condition' which, when using multiple condition statements, will return true if either all statements are true or any of them are true. The second property is the 'Size' which allows you to add multiple condition statements to a single Order. In this example, we are only using 1 condition statement so the first property is irrelevant.

[show our example if statement]

In our example, we have chosen 'Lives' as the Variable to use in our statement. Shown by the example above, the 'Compare With' property is asking you what you want to compare the variable in question with (typically, this field reflects the type of the variable provided so in this case we can only enter integers). Finally, our 'Compare' property is asking what comparison operation we wish to use in our evaluation. In this scenario we are:

  1. Using 'Lives' as the variable
  2. Comparing this with an integer of 0
  3. Using 'Equals' as our operator

This will return true if the varibale 'Lives' is equal to 0 and will indicate a game over state. Orders that encapuslated within condition statements, such as If will be indented to indicate that the condition must evaluate correctly for those orders to be executed. This can be used in tandom with Else Orders and End Orders to indicate the end of a condition statement check.

[show indentation with else and end]

Various Statements Usable

LUTE allows various condition orders to be used such as:

  • If
  • For
  • While
  • ElseIf
  • Else
  • End

These are typically used alongside other Orders and are useful for triggering the loading of other scenes using Scenes>LoadScene.

Collections

Define: Colletion

Define: Collection Types and Variable

Working with Collections

Supporting Collections

Adding New Collections

Clone this wiki locally