Skip to content

Conditionals

Operators

Logical

Operator Description
&& Evaluates as true only if both conditions are true
|| Evaluates as true if either condition is true

Relational

Operator Description Example
== Equal to 1 == 1 -> true
!= No equal to 1 != 1 -> false
> Greater than 2 > 1 -> true
< Less than 2 < 1 -> false
>= Greater than or equal to 2 >= 1 -> true
<= Less than or equal to 2 <= 1 -> false

Blocks

Block statements are similar to C++ & Java.

1
2
3
if (1 + 1 == 2) {

}
1
2
3
4
5
6
7
if (1 + 1 == 2) {
    --[[ math works! ]]
} else if (1 + 1 == 3) {
    --[[ huh? math is not working... ]]
} else {
    --[[ math is still not working ]]
}

Logical Operators

Note

expOrbit uses short-cicuit evaluation for conditionals! In the example below, it will never check if 1 * 1 == 1 since the first check 1 + 1 == 2 will always be true.

1
2
3
if (1 + 1 == 2 || 1 * 1 == 1) {
    --[[ math is working! ]]
}
1
2
3
if (1 + 1 == 2 && 1 * 1 == 1) {
    --[[ math is working ]]
}