Skript is a plugin that allows server admins to customize Minecraft's mechanics without writing any code at all. Everything is written in plain English fragments and phrases. You can create custom commands and events with ease.
Skript files are referred to as "scripts". The file extension for scripts is (.sk) The Skript plugin creates a folder for scripts automatically when you install it. You can find this folder by navigating to plugins / Skript / scripts
through your File Manager. Skript creates default files in the scripts folder to act as references or tutorials. They aren't needed and are disabled by default. Disabled Skript files have a dash before the name Ex. -disabled.sk
/sk reload hello # loads the script with name "hello"/sk reload subFolder/hello.sk # loads the script with name "test", in 'scripts/subFolder/'/sk reload subFolder/ # loads all scripts in 'scripts/subFolder/'/sk reload scripts # loads all scripts
Scripts are made up of multiple lines of code containing Events (triggers), Conditions, Effects, Expressions, Types, and Functions. Functions are less common, but very useful and efficient.
Events or "triggers", are called when something happens on your server. When a player breaks a block, takes damage, or when a mob spawns, are all examples of events. Controlling and making events with Skript will allow you to make something else happen or change the natural event. You can also cancel events. Here's an example.
on explode:cancel event
Take a look at the spacing. After every Event, there is an indentation on the following line. The length of your indentations doesn't matter. All of your indentations must be the same in length however. For example, you could have anywhere from 2-12 spaces as an indent, but all indents must be the same. So you cannot indent 4 spaces in one place, and 6 spaces in another. The example above is made up of two parts; The event and the effect. The first line, "on explode:" is the event. The effect is on the second line. In the example, Skript is cancelling an explode event.
Conditions are an essential addition of Skript. They are parts of code that check to see if a condition is met before executing the rest of your script. Take a look at the structure of conditionals below.
if <condition>:# this section will run if the condition is positiveelse if <condition>:# this section will run if the first condition is negative and the second condition is positiveelse if <condition>:# this section will run if the first two conditions are negative and the third condition is positiveelse:# this section will run if none of the conditions above are positive# Skript also supports in-line conditions which doesn't support 'else if' and 'else', and doesn't start with a "if".# There are examples about this below
else if's
and else
are optional. You can add as many else if
as you want. See the example with permissions below.
on right click:if player has permission "Skript.boom":create explosion with force 3 at targeted block#oron right click:player has permission "Skript.boom"create explosion with force 3 at targeted block
This will create an explosion that is slightly smaller than TNT, but it will only do so if the player has the correct permission.
Effects are actions in your script. Say you want to change the weather with Skript.
command /rain:trigger:set weather to rainy
In the example above, the command "rain" is setting weather to "rainy" or rain.
You can easily create commands with Skript. Check out this tutorial.
Loops are used to repeat tasks to make your script simpler. For example, if you wanted to see if there was a chest near you, you would need to check every block in a certain distance to see if it was a chest. This can be done easily using a loop.
command /chest:trigger:loop blocks in radius 3 around player:if loop-block is a chest:message "There is a chest at %location of loop-block%"
Variables store information under a specific name. Two variables cannot have the same name. Skript will warn you when reloading files that have variable name conflicts.
set {variable name} to true
In the example above, we're setting a variable to true.
Expressions are syntax elements that represent a certain object or value.
set {_online} to amount of players# Here we're setting a variable to the amount of online playerssend "%now%" to player# Here we're sending the current time to the player# The quotations and percentages aren't required in the particular example.# The 'to player' extension is not required in some cases either.
Addons are separate plugins written by other developers to add more functionality to Skript. For example, the Vixio addon allows you to create Discord bots with Skript.
Documentation is extremely helpful when making scripts. They contain a library of Events, Conditions, Effects and more. Here are some popular ones;
SkriptHub - Most accurate, generated from plugin syntaxes.
skUnity - Most popular, has largest documentation.