Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

[Skript Tutorial] Setup & Writing Scripts

Mustafa ÖNCEL edited this page Oct 15, 2019 · 6 revisions

Setup

Download latest SkriptIDE from here. After downloading, open it, if windows gives a warning like "windows protected your computer", it's just a smart screen warning because the given exe does not signed by a coding certificate, coding certificate is a certificate used by companies to get trusted by smart-screen. Just click more information and click open it anyway button. If you don't trust it me or the .exe, you can upload it to virus total and scan for viruses here.

Creating Server

After opening the program, you can see an editor and an example empty script. Choose Server -> New Server... from the menu bar. If you have a Server .JAR file, select it using Select... button. If you don't have a Server .JAR, just download it from here. After selecting your JAR, you have to enter a Server Version for downloading the Skript. The IDE automatically uses this Skript version if you enter "1.7.10", "1.8.8" etc any version between 1.7 and 1.8. But if you enter different versions, e.g 1.9 the IDE just picks up the latest 1.9-1.12+ compatible skript version from the bensku's repo. This can be changed in the future, if you have any ideas, let me know. After all, just click the Create Server button. Wait for progress to complete. After completed, just click the OK button of the given dialog.

Running Skript

After you successfully installed your server from Create Server dialog, Click the Skript -> Execute from the menu bar. This opens a Server Console GUI. It has one option and one button. The "Show only Skript output" option is basically doesn't prints the texts not containing "Skript" to console. The stop server button basically stops the server (not uses stop command, kills the process, use save-all command before killing or just manually use stop if you need) and closes GUI after closing it. Also clicking the X button of the opened Server GUI kills the server. Your script executed after Skript plugin loads.

Adding Addons

Go to SkriptIDE\jars\version-specific\<your version> and put the .JAR files here. Do not change the SkriptIDE\generated or SkriptIDE\scripts folder! These are removed and re-generated before every execution!

Saving Scripts

If you write and test some scripts via Skript -> Execute from the menu bar, you can save it to a real .SK file and upload to your real server via File -> Save.. option from the menu bar.

Writing Scripts

I know Script and Skript are not the same, but I'm using Scripts for the plural version of Skript. The "Skripts" is not meaningful in English. Let's get back to our topic, Writing Scripts. Just use my SkriptIDE or any other Text Editor to write Scripts. Below is some basic tutorial for writing scripts.

Events

The events triggered when an event occurs in Minecraft or Server. For example, if you want to listen for a chat event and respond to messages sent by players, just use the "on chat" event. An example is given below:

on chat:
 if message contains "hi":
  send "hi, %player%!" to player

The above code basically responds to messages containing "hi". If you want to test the above code, just write "hi" or anything contains "hi" to the minecraft chat. After you write, you should receive a message: "hi, <your nickname>!".

Conditions

A condition is a boolean value (true or false) and used via if, else or else if statements. The if, else and else if statements are checks for conditions and continues code based on condition. The above code, chat example, uses a condition "if message contains" this condition checks if some object contains another object. The object is a string in the above code. A string can be any text.

Effects

Effects are operations, the above code, chat example, has an effect named "send". The "send" effect sends a message to an entity. Console, or a player. There are many other effects (operations) can be used in Skript.

Expressions

An expression is a value of an object, or a response/output of an effect. The above code has a expression, "message" is the message sent in the chat event. Expressions can also be inserted inside strings / texts / messages. The above code has an example for inserting expressions into strings, the "hi, %player%!" section in the above code, just replaces %player% by player's name. Skript is smart enough to replace the player object by the player's name. Normally, a player is a person playing on the server, but Skript converts the player into player's name if used as an expression.

Types

Types are types for representing objects. For example, a player is a type representing a person playing on the server, a text is a type representing some string/text. Types generally used in command arguments and function parameters to detect the argument types and parameter types.

Functions

Functions are for naming a code block, turning it to a static named method. For example, you can create a "checkText" function for checking harmful commands/messages, etc., rather than writing checker code every time you check a text. An example is below:

on chat:
 if checkText(message) is true:
  cancel event
  send "don't be argue!" to player
function checkText(t: text) :: boolean:
 if {_t} contains "fuck":
  return true
 return false

Addons

Addons are plugins depending on Skript, these plugins add new Events, Conditions, Effects, Expressions or Types to the Skript.

Tab Key

Skript uses Tab key (the key above Caps Lock) rather than code blocks on other programming languages, so you must put a tab after every ":" character in the above line. Look at the example code, we put a tab in the next line if the above line contains an event, function or condition that ends with ":".

No Semi-Colon

Skript has no semi colons at the end of lines. Don't insert it. (Just a reminder for peoples from other languages)

Go to skUnity documentation for a list of all possible events, conditions, effects etc.