Conditional If/Else
Simple conditional branches for flow control.
The if/else
section is the simplest and most common section, allowing branches in code based on certain conditions.
It forms a tree structure of possible branches.
If Block
These must always start with an if effect as the section header.
If the boolean value in the if %Boolean%
is true, the section under the if
clause will be run.
Instead, if the condition fails, that section will be skipped.
This can be used as an inline section as well.
That second inline if ...
will skip to the end of the current code section, or to the end of the trigger if there is no indent.
Else If Block
An if-block may be followed by an else-if block. This will be run if the condition is met, like the if
section.
If the preceding conditional section passes, the else if...
will be skipped.
An else if...
may not be used on its own. It must have either an if...
or another else if...
directly before it.
After a match is found in an if/else
tree, all following sections will be ignored.
Else Block
An if/else
tree may be finished with one else
block. This does not accept a condition, and runs if none of the preceding conditions passed.
The else block will not be run if a preceding condition passes instead.
Special Behaviour
Multiple conditions can be stacked on one section using a combination of inline and block headers.
This allows multiple conditions to be linked to the same branch of the tree to allow for more complex behaviour.
This behaviour is different from original Skript.
Last updated