## Evaluating ExpressionsEdit

Some operations allow you to mix types, or will return a different type than what they use. It can be important to know what type of value you are getting out of your expressions. For example, all of the comparison operators provide a boolean result (true/false) when run, regardless of what types they are comparing.

Template:KodeShare yes if x is greater than 5, otherwise no.

Template:KodeShare yes if the object set contains the specified object, otherwise no.

But you can also do things like multiply a vector by a number.

is a perfectly reasonable expression.

When you multiply a vector by a number, the result is a vector. In the example, it would be similar to the [world up] vector, but 4 times the length.

Because the result is a vector, you can assign the result of your expression directly to a vector variable, like this:

What you may be noticing at this point is that the order that tiles operate in can be very important. In the above case, first the vector is multiplied by 4, and then the result of that multiplication is assigned to your vector variable.

assignment ([equals], [incremented by] and [decremented by]) is always the last thing to execute

equality checks are nearly the second last thing to execute ([or] and [and] are actually the second last thing to execute)*

The order of operations on numbers is pretty much the same as you are accustomed to in math class: powers, then multiplications/divisions, then additions/subtractions. Modulo executes before additions, but after multiplications.

[*]note, it is uncommon to have both an assignment and an equality check on the same line, but it is valid.

will run fine, though it would be a strange way to write your logic.

You can change the priority of operations using brackets. For example:

WHEN [once] DO [number : average] [equals] [ ( ] [number: x] [plus] [number: y] [ ) ] [divided by] [2]

x and y are added, and then the sum is divided by 2.

Another example, to avoid having the comparison execute before the [and]:

WHEN [ ( ] [boolean : a] [and] [boolean : b] [ ) ] [equal to] [boolean: c]

# Read NextEdit

# Further ReadingEdit