| Patterns: |
|
| Since: | 1.0 |
Conditional sections of judgement
if: executed when its condition doth hold true
else if: executed if all prior chained conditionals were not carried out, and its condition doth hold true
else: executed if all prior chained conditionals were not carried out
parse if: a special case of 'if' condition whereupon the code shall not be parsed if the condition be not true
else parse if: another special case of 'else if' condition whereupon the code shall not be parsed if all prior chained conditionals were not carried out, and its condition doth hold true
if: executed when its condition doth hold true
else if: executed if all prior chained conditionals were not carried out, and its condition doth hold true
else: executed if all prior chained conditionals were not carried out
parse if: a special case of 'if' condition whereupon the code shall not be parsed if the condition be not true
else parse if: another special case of 'else if' condition whereupon the code shall not be parsed if all prior chained conditionals were not carried out, and its condition doth hold true
Examples:
if player's health is greater than or equal to 4:
send "Thy health doth fare well enough, yet tread with care!"
else if player's health is greater than 2:
send "Thou must heal with haste, thy health is most perilously low!"
otherwise: # Fewer than 2 hearts
send "Thou art upon death's very threshold lest thou heal forthwith. Thou hast only %player's health% heart(s)!"
parse if plugin "SomePluginName" is enabled: # parse if %condition%
# This code shall only be executed if the condition be met, otherwise Skript shall not parse this section and therefore shall give no errors nor counsel regarding it
send "Thy health doth fare well enough, yet tread with care!"
else if player's health is greater than 2:
send "Thou must heal with haste, thy health is most perilously low!"
otherwise: # Fewer than 2 hearts
send "Thou art upon death's very threshold lest thou heal forthwith. Thou hast only %player's health% heart(s)!"
parse if plugin "SomePluginName" is enabled: # parse if %condition%
# This code shall only be executed if the condition be met, otherwise Skript shall not parse this section and therefore shall give no errors nor counsel regarding it
| Patterns: |
|
| Since: | 2.12 |
Doth ensnare any runtime faults begotten by code within the section. This be a feature still in progress.
Examples:
ensnare runtime faults:
set worldborder center of {_border} to location(0, 0, NaN value)
if last caught runtime errors contains "Your location can't have a NaN value as one of its components":
set worldborder center of {_border} to location(0, 0, 0)
set worldborder center of {_border} to location(0, 0, NaN value)
if last caught runtime errors contains "Your location can't have a NaN value as one of its components":
set worldborder center of {_border} to location(0, 0, 0)
| Patterns: | |
| Since: | 2.10, 2.14 (stable release) |
A specialised traversal section run for each element within a list. Unlike the basic loop, this is devised for extracting the key & value from pairs. The traversal element's key/index and value may be stored in a variable for convenience.
When traversing a simple (non-indexed) set of values, e.g. all players, the index shall be the traversal counter number.
Examples:
for each {_player} in players:
send "Hail, %{_player}%!" to {_player}
traverse {_item} in {list of items::*}:
broadcast {_item}'s name
for each key {_index} in {list of items::*}:
broadcast {_index}
traverse key {_index} and value {_value} in {list of items::*}:
broadcast "%{_index}% = %{_value}%"
for each {_index}, {_value} in {my list::*}:
broadcast "%{_index}% = %{_value}%"
send "Hail, %{_player}%!" to {_player}
traverse {_item} in {list of items::*}:
broadcast {_item}'s name
for each key {_index} in {list of items::*}:
broadcast {_index}
traverse key {_index} and value {_value} in {list of items::*}:
broadcast "%{_index}% = %{_value}%"
for each {_index}, {_value} in {my list::*}:
broadcast "%{_index}% = %{_value}%"
| Patterns: |
|
| Since: | 2.10 |
Doth loose a projectile (or any other entity) from a given entity or location.
Examples:
loose arrow from all players at speed 2
loose a pig from all players:
add event-entity to {_projectiles::*}
loose a pig from all players:
add event-entity to {_projectiles::*}
| Patterns: |
|
| Since: | 2.10 |
Doth sift a variable list according to the supplied conditions. Unlike the filter expression, this effect preserveth the indices of the sifted list.
It doth also support sifting based upon meeting any of the given criteria, rather than all, akin to multi-line if statements.
It doth also support sifting based upon meeting any of the given criteria, rather than all, akin to multi-line if statements.
Examples:
set {_a::*} to integers between -10 and 10
sift {_a::*} to match:
input is a number
mod(input, 2) = 0
input > 0
send {_a::*} # sends 2, 4, 6, 8, and 10
sift {_a::*} to match:
input is a number
mod(input, 2) = 0
input > 0
send {_a::*} # sends 2, 4, 6, 8, and 10
| Patterns: |
|
| Since: | 1.0, 2.6.1 (with section), 2.8.6 (dropped items), 2.10 (entity snapshots) |
| Requirements: | Minecraft 1.20.2+ (entity snapshots) |
Doth summon entities into being. This may be employed as an effect or as a section.
If employed as a section, the section shall run ere the entity is added unto the world.
Thou mayest modify the entity within this section, using for example 'event-entity' or 'cow'.
Mark well that other event values, such as 'player', shall not function within this section.
If thou art summoning a display and dost wish it to be empty upon initialization, such as not having a block display appear as stone, set the hidden config node 'spawn empty displays' to true.
Note that when summoning an entity by way of entity snapshots, the code within the section shall not run instantaneously as compared to summoning by the usual means (via 'a zombie').
If employed as a section, the section shall run ere the entity is added unto the world.
Thou mayest modify the entity within this section, using for example 'event-entity' or 'cow'.
Mark well that other event values, such as 'player', shall not function within this section.
If thou art summoning a display and dost wish it to be empty upon initialization, such as not having a block display appear as stone, set the hidden config node 'spawn empty displays' to true.
Note that when summoning an entity by way of entity snapshots, the code within the section shall not run instantaneously as compared to summoning by the usual means (via 'a zombie').
Examples:
summon 3 creepers at the targeted block
conjure a ghast 5 meters above the player
summon a zombie at the player:
set name of the zombie to ""
conjure a block display of a ladder[waterlogged=true] at location above player:
set billboard of event-display to center # permits the display to rotate about the centre axis
conjure a ghast 5 meters above the player
summon a zombie at the player:
set name of the zombie to ""
conjure a block display of a ladder[waterlogged=true] at location above player:
set billboard of event-display to center # permits the display to rotate about the centre axis
| Patterns: |
|
| Since: | 1.0 |
Traversal sections do repeat their code with manifold values.
A traversal shall iterate through all elements of the given expression, e.g. all players, worlds, items, et cetera. The conditions & effects within the traversal shall be executed for every one of those elements, which may be accessed with 'loop-', e.g.
Traversable Values
All expressions that represent more than one value, e.g. 'all players', 'worlds', et cetera, as well as list variables, may be traversed. Thou mayest also employ a list of expressions, e.g.
List Variables
When traversing list variables, thou mayest also use
A traversal shall iterate through all elements of the given expression, e.g. all players, worlds, items, et cetera. The conditions & effects within the traversal shall be executed for every one of those elements, which may be accessed with 'loop-
send "hail" to loop-player. When a condition within a traversal is not fulfilled, the traversal shall recommence with the next element. Thou mayest however use stop loop to depart the traversal entirely and resume code execution after its end.Traversable Values
All expressions that represent more than one value, e.g. 'all players', 'worlds', et cetera, as well as list variables, may be traversed. Thou mayest also employ a list of expressions, e.g.
traverse the victim and the attacker, to execute the same code for but a few values.List Variables
When traversing list variables, thou mayest also use
loop-index in addition to loop-value within the traversal. loop-value is the value of the currently traversed variable, and loop-index is the last part of the variable's name (the part where the list variable hath its asterisk *). Examples:
traverse all players:
send "Hail, %loop-player%!" to loop-player
traverse items in player's inventory:
if loop-item is dirt:
set loop-item to air
traverse 10 times:
send title "%11 - loop-value%" and subtitle "seconds remain ere the contest doth begin" to player for 1 second # 10, 9, 8 etc.
wait 1 second
traverse {Coins::*}:
set {Coins::%loop-index%} to loop-value + 5 # Same as "add 5 to {Coins::%loop-index%}" where loop-index is the uuid of " +
"the player and loop-value is the number of coins for the player
traverse shuffled (integers between 0 and 8):
if all:
previous loop-value = 1
loop-value = 4
next loop-value = 8
then:
kill all players
send "Hail, %loop-player%!" to loop-player
traverse items in player's inventory:
if loop-item is dirt:
set loop-item to air
traverse 10 times:
send title "%11 - loop-value%" and subtitle "seconds remain ere the contest doth begin" to player for 1 second # 10, 9, 8 etc.
wait 1 second
traverse {Coins::*}:
set {Coins::%loop-index%} to loop-value + 5 # Same as "add 5 to {Coins::%loop-index%}" where loop-index is the uuid of " +
"the player and loop-value is the number of coins for the player
traverse shuffled (integers between 0 and 8):
if all:
previous loop-value = 1
loop-value = 4
next loop-value = 8
then:
kill all players
| Patterns: |
|
| Since: | 2.0, 2.6 (do while) |
Whilst Loop sections are loops that shall persist in their repetition so long as a condition doth hold true.
Examples:
whilst size of all players < 5:
send "More souls are needed to commence the adventure" to all players
wait 5 seconds
set {_counter} to 1
do whilst {_counter} > 1: # false, yet 'twill increase {_counter} by 1 then depart
add 1 to {_counter}
# Take heed when employing whilst loops with conditions that hold true
# for great spans without using 'wait %timespan%' within,
# lest it hang and bring ruin upon thy server.
whilst player is online:
give player 1 dirt
wait 1 second # without a delay effect the server shall surely crash
send "More souls are needed to commence the adventure" to all players
wait 5 seconds
set {_counter} to 1
do whilst {_counter} > 1: # false, yet 'twill increase {_counter} by 1 then depart
add 1 to {_counter}
# Take heed when employing whilst loops with conditions that hold true
# for great spans without using 'wait %timespan%' within,
# lest it hang and bring ruin upon thy server.
whilst player is online:
give player 1 dirt
wait 1 second # without a delay effect the server shall surely crash