Skip to content

Commit ae0f919

Browse files
authored
add new 2.7 stuff
1 parent e251180 commit ae0f919

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

core-concepts/indentation/conditionals.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,42 @@ Keep note that there is no `else if` or `else` options with this method.
158158

159159
## If Any and If All
160160

161-
new 2.7 shit
161+
So what happens if you want to check a bunch of conditions? While you *can* use Inline Ifs or create a huge indentation pyramids, there is a much better way. Skript's `if any` and `if all` statements allow for multiple conditions in *the same condition*. This is super useful when you have tons of conditions like so:
162+
163+
```applescript
164+
if:
165+
player's gamemode is survival
166+
player is swimming
167+
player is wearing a turtle helmet
168+
player is holding a trident
169+
player's tool is enchanted with riptide
170+
name of player is "Aquaman"
171+
then:
172+
send "You passed all the conditions!" to player
173+
else:
174+
send "You didn't meet all the conditions! to player
175+
```
176+
177+
{% hint style="info" %}
178+
Notice the `else` statement! These multi-conditions can include `else if` and `else` statements inside of them!
179+
{% endhint %}
180+
181+
This works well because we can check multiple conditions without losing code quality. But what if we only need a single condition to be met out of many? For example, what if we want **both** admins and builders to have build permission? In that case, we can use `if any` like this:
182+
183+
```applescript
184+
on block place:
185+
if any:
186+
player is op
187+
player's gamemode is creative
188+
name of player is "BobTheBuilder"
189+
then:
190+
send "You placed a block!" to player
191+
else:
192+
send "You don't have permission to place blocks!" to player
193+
cancel event
194+
```
195+
196+
When **at least** one condition is met, the player will be able to place the block. However, if none of the conditions are met, the event will be cancelled.
162197

163198
## Ternary Operators
164199

0 commit comments

Comments
 (0)