Expressions

All Scripts

🔗

Expression

Patterns:
  • [all [of the]|the] scripts [without ([subdirectory] paths|parents)]
  • [all [of the]|the] (enabled|loaded) scripts [without ([subdirectory] paths|parents)]
  • [all [of the]|the] (disabled|unloaded) scripts [without ([subdirectory] paths|parents)]
Since: 2.5
Return Type: Text
Returns all of the scripts, or just the enabled or disabled ones.

Examples:

command /scripts:
    trigger:
        send "All Scripts: %scripts%" to player
        send "Loaded Scripts: %enabled scripts%" to player
        send "Unloaded Scripts: %disabled scripts%" to player

Case Text

🔗

Expression

Patterns:
  • %texts% in (upper|lower)[ ]case
  • (upper|lower)[ ]case %texts%
  • capitali(s|z)ed %texts%
  • %texts% in [(lenient|strict) ](proper|title)[ ]case
  • [(lenient|strict) ](proper|title)[ ]case %texts%
  • %texts% in [(lenient|strict) ]camel[ ]case
  • [(lenient|strict) ]camel[ ]case %texts%
  • %texts% in [(lenient|strict) ]pascal[ ]case
  • [(lenient|strict) ]pascal[ ]case %texts%
  • %texts% in [(lower|upper|capital|screaming)[ ]]snake[ ]case
  • [(lower|upper|capital|screaming)[ ]]snake[ ]case %texts%
  • %texts% in [(lower|upper|capital)[ ]]kebab[ ]case
  • [(lower|upper|capital)[ ]]kebab[ ]case %texts%
Since: 2.2-dev16 (lowercase and uppercase), 2.5 (advanced cases)
Return Type: Text
Copy of given text in Lowercase, Uppercase, Proper Case, camelCase, PascalCase, Snake_Case, and Kebab-Case

Examples:

"Oops!" in lowercase # oops!
"oops!" in uppercase # OOPS!
"hellO i'm steve!" in proper case # HellO I'm Steve!
"hellO i'm steve!" in strict proper case # Hello I'm Steve!
"spAwn neW boSs ()" in camel case # spAwnNeWBoSs()
"spAwn neW boSs ()" in strict camel case # spawnNewBoss()
"geneRate ranDom numBer ()" in pascal case # GeneRateRanDomNumBer()
"geneRate ranDom numBer ()" in strict pascal case # GenerateRandomNumber()
"Hello Player!" in snake case # Hello_Player!
"Hello Player!" in lower snake case # hello_player!
"Hello Player!" in upper snake case # HELLO_PLAYER!
"What is your name?" in kebab case # What-is-your-name?
"What is your name?" in lower kebab case # what-is-your-name?
"What is your name?" in upper kebab case # WHAT-IS-YOUR-NAME?

Characters Between

🔗

Expression

Patterns:
  • [(all [[of] the]|the)] [alphanumeric] characters (between|from) %text% (and|to) %text%
Since: 2.8.0
Return Type: Text
All characters between two given characters, useful for generating random strings. This expression uses the Unicode numerical code of a character to determine which characters are between the two given characters. The ASCII table linked here shows this ordering for the first 256 characters. If you would like only alphanumeric characters you can use the 'alphanumeric' option in the expression. If strings of more than one character are given, only the first character of each is used.

Examples:

loop characters from "a" to "f":
    broadcast "%loop-value%"

# 0123456789:;<=>?@ABC... ...uvwxyz
send characters between "0" and "z"

# 0123456789ABC... ...uvwxyz
send alphanumeric characters between "0" and "z"

Colored / Uncolored

🔗

Expression

Patterns:
  • (colo[u]r-|colo[u]red )%texts%
  • (format-|formatted )%texts%
  • (un|non)[-](colo[u]r-|colo[u]red |format-|formatted )%texts%
Since: 2.0
Return Type: Text
Parses <color>s and, optionally, chat styles in a message or removes any colors and chat styles from the message. Parsing all chat styles requires this expression to be used in same line with the send effect.

Examples:

on chat:
    set message to colored message # Safe; only colors get parsed
command /fade &lt;player&gt;:
    trigger:
        set display name of the player-argument to uncolored display name of the player-argument
command /format &lt;text&gt;:
    trigger:
        message formatted text-argument # Safe, because we're sending to whoever used this command

Date Ago/Later

🔗

Expression

Patterns:
Since: 2.2-dev33
Return Type: Date
A date the specified timespan before/after another date.

Examples:

set {_yesterday} to 1 day ago
set {_hourAfter} to 1 hour after {someOtherDate}
set {_hoursBefore} to 5 hours before {someOtherDate}

Hash

🔗

Expression

Patterns:
  • %texts% hash[ed] with (MD5|SHA-256)
Since: 2.0, 2.2-dev32 (SHA-256 algorithm)
Return Type: Text
Hashes the given text using the MD5 or SHA-256 algorithms. Each algorithm is suitable for different use cases.

MD5 is provided mostly for backwards compatibility, as it is outdated and not secure. SHA-256 is more secure, and can used to hash somewhat confidental data like IP addresses and even passwords. It is not that secure out of the box, so please consider using salt when dealing with passwords! When hashing data, you must specify algorithms that will be used for security reasons!

Please note that a hash cannot be reversed under normal circumstanses. You will not be able to get original value from a hash with Skript.

Examples:

command /setpass &lt;text&gt;:
    trigger:
        set {password::%uuid of player%} to text-argument hashed with SHA-256
command /login &lt;text&gt;:
    trigger:
        if text-argument hashed with SHA-256 is {password::%uuid of player%}:
            message "Login successful."
        else:
            message "Wrong password!"

Index Of

🔗

Expression

Patterns:
  • [the] [(first|last)] index of %text% in %text%
Since: 2.1
Return Type: long
The first or last index of a character (or text) in a text, or -1 if it doesn't occur in the text. Indices range from 1 to the length of the text.

Examples:

set {_first} to the first index of "@" in the text argument
if {_s} contains "abc":
    set {_s} to the first (index of "abc" in {_s} + 3) characters of {_s} # removes everything after the first "abc" from {_s}

Indices of List

🔗

Expression

Patterns:
  • [(the|all [[of] the])] (indexes|indices) of %~objects%
  • %~objects%'[s] (indexes|indices)
  • [sorted] (indices|indexes) of %~objects% in (ascending|descending) order
  • [sorted] %~objects%'[s] (indices|indexes) in (ascending|descending) order
Since: 2.4 (indices), 2.6.1 (sorting)
Return Type: Text
Returns all the indices of a list variable, optionally sorted by their values. To sort the indices, all objects in the list must be comparable; Otherwise, this expression will just return the unsorted indices.

Examples:

set {l::*} to "some", "cool" and "values"
broadcast "%indices of {l::*}%" # result is 1, 2 and 3

set {_leader-board::first} to 17
set {_leader-board::third} to 30
set {_leader-board::second} to 25
set {_leader-board::fourth} to 42
set {_ascending-indices::*} to sorted indices of {_leader-board::*} in ascending order
broadcast "%{_ascending-indices::*}%" #result is first, second, third, fourth
set {_descending-indices::*} to sorted indices of {_leader-board::*} in descending order
broadcast "%{_descending-indices::*}%" #result is fourth, third, second, first

Length

🔗

Expression

Patterns:
Since: 2.1
Return Type: long
The length of a text, in number of characters.

Examples:

set {_l} to length of the string argument

Loaded Plugins

🔗

Expression

Patterns:
  • [(all [[of] the]|the)] [loaded] plugins
Since: 2.7
Return Type: Text
An expression to obtain a list of the names of the server's loaded plugins.

Examples:

if the loaded plugins contains "Vault":
    broadcast "This server uses Vault plugin!"

send "Plugins (%size of loaded plugins%): %plugins%" to player

Loop Iteration

🔗

Expression

Patterns:
  • [the] loop(-| )(counter|iteration)[-%*number%]
Since: 2.8.0
Return Type: long
Returns the loop's current iteration count (for both normal and while loops).

Examples:

while player is online:
    give player 1 stone
    wait 5 ticks
    if loop-counter > 30:
        stop loop

loop {top-balances::*}:
    if loop-iteration <= 10:
        broadcast "##%loop-iteration% %loop-index% has $%loop-value%"

Loop value

🔗

Expression

Patterns:
  • [the] loop-<.+>
Since: 1.0, 2.8.0 (loop-counter)
Return Type: Object
Returns the currently looped value.

Examples:

# Countdown
loop 10 times:
    message "%11 - loop-number%"
    wait a second

# Generate a 10x10 floor made of randomly colored wool below the player
loop blocks from the block below the player to the block 10 east of the block below the player:
    loop blocks from the loop-block to the block 10 north of the loop-block:
        set loop-block-2 to any wool

loop {top-balances::*}:
    loop-iteration <= 10
    send "##%loop-iteration% %loop-index% has $%loop-value%"

Now

🔗

Expression

Patterns:
  • now
Since: 1.4
Return Type: Date
The current system time of the server. Use time to get the Minecraft time of a world.

Examples:

broadcast "Current server time: %now%"

Number of Characters

🔗

Expression

Patterns:
  • number of upper[ ]case char(acters|s) in %text%
  • number of lower[ ]case char(acters|s) in %text%
  • number of digit char(acters|s) in %text%
Since: 2.5
Return Type: long
The number of uppercase, lowercase, or digit characters in a string.

Examples:

#Simple Chat Filter
on chat:
    if number of uppercase chars in message / length of message > 0.5
        cancel event
        send "&lt;red&gt;Your message has to many caps!" to player

Numbers

🔗

Expression

Patterns:
  • [(all [[of] the]|the)] (numbers|integers|decimals) (between|from) %number% (and|to) %number%
Since: 1.4.6 (integers & numbers), 2.5.1 (decimals)
Return Type: Number
All numbers between two given numbers, useful for looping. Use 'numbers' if your start is not an integer and you want to keep the fractional part of the start number constant, or use 'integers' if you only want to loop integers. You may also use 'decimals' if you want to use the decimal precision of the start number. You may want to use the 'times' expression instead, for instance 'loop 5 times:'

Examples:

loop numbers from 2.5 to 5.5: # loops 2.5, 3.5, 4.5, 5.5
loop integers from 2.9 to 5.1: # same as '3 to 5', i.e. loops 3, 4, 5
loop decimals from 3.94 to 4: # loops 3.94, 3.95, 3.96, 3.97, 3.98, 3.99, 4

Parse

🔗

Expression

Patterns:
Since: 2.0
Return Type: Object
Parses text as a given type, or as a given pattern. This expression can be used in two different ways: One which parses the entire text as a single instance of a type, e.g. as a number, and one that parses the text according to a pattern. If the given text could not be parsed, this expression will return nothing and the parse error will be set if some information is available. Some notes about parsing with a pattern: - The pattern must be a Skript pattern, e.g. percent signs are used to define where to parse which types, e.g. put a %number% or %items% in the pattern if you expect a number or some items there. - You have to save the expression's value in a list variable, e.g. set {parsed::*} to message parsed as "...". - The list variable will contain the parsed values from all %types% in the pattern in order. If a type was plural, e.g. %items%, the variable's value at the respective index will be a list variable, e.g. the values will be stored in {parsed::1::*}, not {parsed::1}.

Examples:

set {var} to line 1 parsed as number
on chat:
    set {var::*} to message parsed as "buying %items% for %money%"
    if parse error is set:
        message "%parse error%"
    else if {var::*} is set:
        cancel event
        remove {var::2} from the player's balance
        give {var::1::*} to the player

Parse Error

🔗

Expression

Patterns:
  • [the] [last] [parse] error
Since: 2.0
Return Type: Text
The error which caused the last parse operation to fail, which might not be set if a pattern was used and the pattern didn't match the provided text at all.

Examples:

set {var} to line 1 parsed as integer
if {var} is not set:
    parse error is set:
        message "&lt;red&gt;Line 1 is invalid: %last parse error%"
    else:
        message "&lt;red&gt;Please put an integer on line 1!"

Percent of

🔗

Expression

Patterns:
Since: 2.8.0
Return Type: Number
Returns a percentage of one or more numbers.

Examples:

set damage to 10% of victim's health
set damage to 125 percent of damage
set {_result} to {_percent} percent of 999
set {_result::*} to 10% of {_numbers::*}
set experience to 50% of player's total experience

Question

🔗

Expression

Patterns:
Since: 3.0
Return Type: Text
Asks a question and returns the answer.

Examples:

set {answer} to answer of "What is your name?"

Random

🔗

Expression

Patterns:
Since: 1.4.9
Return Type: Object
Gets a random item out of a set, e.g. a random player out of all players online.

Examples:

give a diamond to a random player out of all players
give a random item out of all items to the player

Random Character

🔗

Expression

Patterns:
  • [a|%integer%] random [alphanumeric] character[s] (from|between) %text% (to|and) %text%
Since: 2.8.0
Return Type: Text
One or more random characters between two given characters. Use 'alphanumeric' if you want only alphanumeric characters. This expression uses the Unicode numerical code of a character to determine which characters are between the two given characters. If strings of more than one character are given, only the first character of each is used.

Examples:

set {_captcha} to join (5 random characters between "a" and "z") with ""
send 3 random alphanumeric characters between "0" and "z"

Random Number

🔗

Expression

Patterns:
  • [a] random (integer|number) (from|between) %number% (to|and) %number%
Since: 1.4
Return Type: Number
A random number or integer between two given numbers. Use 'number' if you want any number with decimal parts, or use use 'integer' if you only want whole numbers. Please note that the order of the numbers doesn't matter, i.e. random number between 2 and 1 will work as well as random number between 1 and 2.

Examples:

set the player's health to a random number between 5 and 10
send "You rolled a %random integer from 1 to 6%!" to the player

Random UUID

🔗

Expression

Patterns:
  • [a] random uuid
Since: 2.5.1
Return Type: Text
Returns a random UUID.

Examples:

set {_uuid} to random uuid

Repeat String

🔗

Expression

Patterns:
  • %texts% repeated %integer% time[s]
Since: 2.8.0
Return Type: Text
Repeats inputted strings a given amount of times.

Examples:

broadcast nl and nl repeated 200 times
broadcast "Hello World " repeated 5 times
if "aa" repeated 2 times is "aaaa":
    broadcast "Ahhhh" repeated 100 times

Reversed List

🔗

Expression

Patterns:
Since: 2.4
Return Type: Object
Reverses given list.

Examples:

set {_list::*} to reversed {_list::*}

Rounding

🔗

Expression

Patterns:
  • [(a|the)] round[ed] down %number%
  • [(a|the)] round[ed] %number%
  • [(a|the)] round[ed] up %number%
Since: 2.0
Return Type: long
Rounds numbers normally, up (ceiling) or down (floor) respectively.

Examples:

set {var} to rounded health of player
set line 1 of the block to rounded "%(1.5 * player's level)%"
add rounded down argument to the player's health

Script Name

🔗

Expression

Patterns:
  • [the] script[['s] name]
  • name of [the] script
Since: 2.0
Usable in events: Script Load/Unload
Return Type: Text
Holds the current script's name (the file name without '.sk').

Examples:

on script load:
    set {running::%script%} to true
on script unload:
    set {running::%script%} to false

Sets

🔗

Expression

Patterns:
  • [all [[of] the]|the|every] %*type%
Since: 1.0 pre-5, 2.7 (classinfo)
Return Type: Object
Returns a list of all the values of a type. Useful for looping.

Examples:

loop all attribute types:
    set loop-value attribute of player to 10
    message "Set attribute %loop-value% to 10!"

Shuffled List

🔗

Expression

Patterns:
Since: 2.2-dev32
Return Type: Object
Shuffles given list randomly. This is done by replacing indices by random numbers in resulting list.

Examples:

set {_list::*} to shuffled {_list::*}

Sorted List

🔗

Expression

Patterns:
Since: 2.2-dev19
Return Type: Object
Sorts given list in natural order. All objects in list must be comparable; if they're not, this expression will return nothing.

Examples:

set {_sorted::*} to sorted {_players::*}

Substring

🔗

Expression

Patterns:
  • [the] (part|sub[ ](text|string)) of %texts% (between|from) [ind(ex|ices)|character[s]] %number% (and|to) [(index|character)] %number%
  • [the] (first|last) [%number%] character[s] of %texts%
  • [the] %number% (first|last) characters of %texts%
  • [the] character[s] at [(index|position|indexes|indices|positions)] %numbers% (in|of) %texts%
Since: 2.1, 2.5.2 (character at, multiple strings support)
Return Type: Text
Extracts part of a text. You can either get the first <x> characters, the last <x> characters, the character at index <x>, or the characters between indices <x> and <y>. The indices <x> and <y> should be between 1 and the length of the text (other values will be fit into this range).

Examples:

set {_s} to the first 5 characters of the text argument
message "%subtext of {_s} from characters 2 to (the length of {_s} - 1)%" # removes the first and last character from {_s} and sends it to the player or console
set {_characters::*} to characters at 1, 2 and 7 in player's display name
send the last character of all players' names

Time Since

🔗

Expression

Patterns:
  • [the] time since %dates%
Since: 2.5
Return Type: Timespan
The time that has passed since a date. If the given date is in the future, a value will not be returned.

Examples:

send "%time since 5 minecraft days ago% has passed since 5 minecraft days ago!" to player

Unix Date

🔗

Expression

Patterns:
Since: 2.5
Return Type: Date
Converts given Unix timestamp to a date. The Unix timespan represents the number of seconds elapsed since 1 January 1970.

Examples:

unix date of 946684800 #1 January 2000 12:00 AM (UTC Time)

Unix Timestamp

🔗

Expression

Patterns:
  • [the] unix timestamp of %dates%
  • %dates%'[s] unix timestamp
Since: 2.2-dev31
Return Type: Number
Converts given date to Unix timestamp. This is roughly how many seconds have elapsed since 1 January 1970.

Examples:

unix timestamp of now

Value Within

🔗

Expression

Patterns:
Since: 2.7
Return Type: Object
Gets the value within objects. Usually used with variables to get the value they store rather than the variable itself, or with lists to get the values of a type.

Examples:

set {_entity} to a random entity out of all entities
delete entity within {_entity} # This deletes the entity itself and not the value stored in the variable

set {_list::*} to "something", 10, "test" and a zombie
broadcast the strings within {_list::*} # "something", "test"