If / Else¶
If Statements¶
If statements use the if keyword followed by a condition wrapped in parentheses.
For information on how to write conditions, see Conditional Expressions. For basic conditions, use the tool below.
Expand this box to convert If Actions to their Terracotta equivalents
Click on "If Player" to change to a different code block.
Inverting (NOT arrow equivalent)¶
To invert the entirety of an if statement's condition, an exclamation point ! can be placed in front of the condition's parentheses.
// these both do the exact same thing
if !(condition) {}
if (!condition) {}
// these both do the exact same thing
if !(a && b) {}
if (!(a && b)) {}
Else Statements¶
Else statements can be placed immediately after an if statement using the else keyword.
Else-If Statements¶
Else if statements are also supported. They must be placed after the if statement but before the final else statement.
You can have as many else if statements as you want and conditions can be arbitrarily complex.