You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This gitbook contains a crash course in Skript programming, so if you're here to learn, you're in the right place. This page contains the very basic overview of Skript, including installation and some basic ideas on how Skript works. We'll walk you through writing your first script, and hopefully get you more confident in using the language. After that, you can explore the rest of this site for more in-depth explanations and higher-level concepts. To get started, just click the `Installation` link at the bottom of this page.
6
6
@@ -11,14 +11,6 @@ For those of you who are already familiar with Skript, go ahead and use the navi
Copy file name to clipboardExpand all lines: introduction/installation.md
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,11 @@
3
3
Installing Skript is no different from any other plugin. You download the latest jar file, which can be found at [https://github.com/SkriptLang/Skript/releases](https://github.com/SkriptLang/Skript/releases). You should ensure your server meets the requirements for running Skript:
4
4
5
5
* A Spigot, Paper, or Paper fork server jar. Spigot is the absolute minimum and Skript includes some features that are only accessible when using Paper or a fork of Paper.
6
-
* Minecraft Version. Currently, 2.6.3 works for 1.9 - 1.19, but 2.7 will only work for 1.13+. 
6
+
* Minecraft Version. Currently, 2.6.4 works for 1.9 - 1.19.3, but 2.7 will only work for 1.13+. 
7
7
* 1.8 support can be found [here](https://github.com/Matocolotoe/Skript-1.8/releases), but is not official, nor recommended, nor guaranteed to work.
8
8
9
9
After you've downloaded the jar file, put it in your `plugins` folder in your server directory. Restart the server and Skript should generate the folder `plugins/Skript`. 
10
10
11
11
Inside should be some files, `config.sk`, and the folder `scripts`. The `scripts` folder should have a folder of example scripts inside it. These are very useful for understanding how scripts are written.
12
+
13
+
You can take some time to read through them, or you can move directly on to making your first script.
Copy file name to clipboardExpand all lines: introduction/the-basics.md
+33-20Lines changed: 33 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,16 @@
1
1
# The Basics
2
2
3
-
This page will walk you through creating your first script. If this is too slow for you, feel free to jump ahead to the [Core Concepts](broken-reference) section. This is just to get you comfortable with the very basics of Skript.
3
+
This page will walk you through creating your first script. If this is too slow for you, feel free to jump ahead to the [Core Concepts](broken-reference/) section. This is just to get you comfortable with the very basics of Skript.
4
4
5
5
### Creating the Script File
6
6
7
-
First things first, we need somewhere to write our code. Inside the `plugins/Skript/scripts` folder, create a new text file. Name it `first-script.sk`. The `.sk` tells Skript that this is a script, and is important. You can name Skript files whatever you want, as long as they end in `.sk`. Just don't use `-` to start the name, as Skript uses that to denote disabled scripts: `-example.sk`.
7
+
First things first, we need somewhere to write our code. Inside the `plugins/Skript/scripts` folder, create a new text file. Name it `first-script.sk`. The `.sk` tells Skript that this is a script and that it needs to pay attention to it. You can name Skript files whatever you want, as long as they end in `.sk`. Just don't use `-` to start the name, as Skript uses that to denote disabled scripts: `-example.sk`.
8
8
9
-
Now you've got an empty file to play around in. You can write Skript in whatever editor you want, Notepad, Sublime, etc. Personally, I use Visual Studio Code as there are some nice formatting extensions for it. It's up to you.
9
+
{% hint style="info" %}
10
+
#### What program should I use to write Skript code?
11
+
12
+
Any text editor works fine for writing Skript. Some, like Atom, Sublime Text, and Visual Studio Code have themes or extensions that highlight Skript's syntax to make it easier to read.
13
+
{% endhint %}
10
14
11
15
### Writing a Simple Command
12
16
@@ -19,23 +23,26 @@ command /food:
19
23
# this is where the code will go
20
24
```
21
25
22
-
So we have two lines so far, the first one telling Skript that we're making a new command, and that it's named `/food`. The lines with `#` are comments and are just there for explanation; they don't affect the code. Now we need to tell Skript what the command does, which is what `trigger` does. There are other things that commands can have, which you can look at the core concepts page for. 
26
+
So we have two lines so far, the first one telling Skript that we're making a new command, and that it's named `/food`. The lines with `#` are comments and are just there for explanation; they don't affect the code. Now we need to tell Skript what the command does, which is what `trigger` does. There are other things that commands can have, which you can look at the core concepts page for.
27
+
28
+
{% hint style="info" %}
29
+
#### Indentation
23
30
24
31
You might also notice we've indented the `trigger:`. This is a really important concept in Skript. Indenting tells Skript what belongs to what. Everything indented after the `command` line belongs to that command, and if you un-indent, Skript thinks it is going to be something else. **The basic rule of thumb is to indent every time you see a colon (`:`)**, but there's more information on indentation [here](../core-concepts/indentation/).
32
+
{% endhint %}
25
33
26
-
Sotrigger is responsible for holding all the code that runs when the command is called by a player. Let's add a line that fills up a player's hunger bar. We can consult the docs for this one. Head to [https://docs.skriptlang.org/](https://docs.skriptlang.org/), click on `Expressions`, and search for "Food" or "Hunger". 
34
+
So, `trigger` is responsible for holding all the code that runs when the command is called by a player. Let's add some code for it to hold! 
27
35
28
-
You should see one result, called Food Level. If you look at the patterns, you can see that `player`, `food`, and `level` all show up in there. It might be a bit hard to read, which is why we have a [syntax reading tutorial](../syntax-types/reading-syntax.md), but it's pretty simple once you know how. For now, we'll just look at the example. 
36
+
We want a code that fills the player's hunger bar, but we don't know what to write. We can consult the docs for some help. If you'll indulge me, head to [https://docs.skriptlang.org/](https://docs.skriptlang.org/), click on `Expressions`, and search for "Food" or "Hunger". 
29
37
30
-
```applescript
31
-
set the player's food level to 10
32
-
```
38
+
{% hint style="warning" %}
39
+
This may seem annoying, or frivolous, but please actually visit the docs. They're your best tool for finding what you need when you have questions.
40
+
{% endhint %}
33
41
34
-
We can also do some addition and subtraction really easily:
42
+
You should see one result, called Food Level. If you look at the patterns, you can see that `player`, `food`, and `level` all show up in there. It might be a bit hard to read, which is why we have a [syntax reading tutorial](../syntax-types/reading-syntax.md), but it's pretty simple once you know how. For now, we'll just look at the example.
35
43
36
44
```applescript
37
-
add 2 to the player's food level
38
-
subtract 3 from the player's food level
45
+
set the player's food level to 10
39
46
```
40
47
41
48
Before we get ahead of ourselves, though, we need to talk about `the player`. In commands, the person who executes the command can be referred to as `player`, or `sender`. However, we don't always have `player` to help us out. Sometimes we'll have to get a player from a variable (explained later), or from an event value:
@@ -57,7 +64,7 @@ command /food:
57
64
58
65
Perfect! A simple, easy food command. It doesn't seem very fun though. Let's give the food to the players instead, so they have something to actually eat. See if you can use the docs to find what `effect` we need to give items to players.
59
66
60
-
Spoilers: it's `give`:
67
+
Spoilers: it's `give`.
61
68
62
69
```applescript
63
70
command /food:
@@ -76,9 +83,10 @@ command /food:
76
83
77
84
Technically, we could just write `send "You received some food!"` and Skript would know who we meant to send it to, but it's good practice to be explicit in what you're doing when writing code.
78
85
86
+
{% hint style="info" %}
79
87
#### Note on Using Text in Skript
80
88
81
-
Notice that all the text we want to send is surrounded by `"`. Surrounding the text with `"` is important because it tells Skript that the stuff inside isn't code, it's just some text that shouldn't really be bothered with. Text that's just text and isn't part of the actual code is referred to as a `string` in programming terminology. In Skript you'll hear it referred to as `text` and `string` interchangeably. 
89
+
Notice that all the text we want to send is surrounded by `"`. Surrounding the text with `"` is important because it tells Skript that the stuff inside isn't code, it's just some text that shouldn't really be bothered with. Text that's just text and isn't part of the actual code is referred to as a `string` in programming terminology. In Skript you'll hear it referred to as `text` and `string` interchangeably.
82
90
83
91
Note that there are some rules surrounding text that might be confusing at first. If you want to use `"`, `#`, or `%` in a string, you have to type two of them in a row. This is because Skript uses these symbols for important things, and typing two in a row tells Skript to just treat it as one, normal, non-code character.
84
92
@@ -101,6 +109,7 @@ send "5 + 10 = %5 + 10%" to player
101
109
```
102
110
103
111
You can read more about the things you can and can't do with strings [here](../core-concepts/text.md).
112
+
{% endhint %}
104
113
105
114
### If/Else
106
115
@@ -156,9 +165,9 @@ command /food:
156
165
send "You receieved some food!" to player
157
166
```
158
167
159
-
Here, we've set the different items that the player will get to the `{_item}` variable. We can then use that after the `if` to give the right item to the player. If they're an op, `{_item}` will be set to 2 golden apples, otherwise it'll be 2 steak. 
168
+
Here, we've set the different items that the player will get to the `{_item}` variable. We can then use that after the `if` to give the right item to the player. If they're an op, `{_item}` will be set to 2 golden apples, otherwise it'll be 2 steak.
160
169
161
-
Variables are explained further [here](../core-concepts/variables/), in the [Core Concepts](broken-reference) section.
170
+
Variables are explained further [here](../core-concepts/variables/), in the [Core Concepts](broken-reference/) section.
162
171
163
172
### Expressions in Text
164
173
@@ -177,7 +186,8 @@ command /food:
177
186
178
187
The `%%` tell Skript to pay attention and read the stuff inside as code instead of just as text. This means we can just put `{_item}` in there and "2 steaks" or "2 golden apples" will automatically be sent to the player. `%%` can also be used in variable names, like`{variable::%player's uuid}`, which is a good way to make global variables specific to one player. Global and local variables are explained [here](../core-concepts/variables/global-and-local.md).
179
188
180
-
However, %% should only ever be used in those two situations: inside a string, or inside a variable. You should not be using it outside of that. 
189
+
{% hint style="warning" %}
190
+
However, %% should only ever be used in those two situations: inside a string, or inside a variable. You should not be using it outside of that.
181
191
182
192
```applescript
183
193
# BAD
@@ -188,6 +198,7 @@ set %player's tool% to stone
188
198
send "%event-item%" to player
189
199
set {_tool-text} to "%player's tool%"
190
200
```
201
+
{% endhint %}
191
202
192
203
### Using Events
193
204
@@ -243,8 +254,10 @@ on consume of rotten flesh:
243
254
244
255
### Conclusion
245
256
246
-
Congrats on writing your first script! This was only a small part of what you can do with Skript, but I hope it helped you get your feet wet. To learn more, check out the [Core Concepts](broken-reference) pages for more in-depth tutorials. You should also become familiar with the official docs, or with SkriptHub docs if you prefer those. They'll help you tremendously. 
247
-
248
-
If you had trouble following along, or didn't like this tutorial for some reason, please either message me on Discord at Sovde#0001, or open an issue on the github repository for this site.
257
+
Congrats on writing your first script! This was only a small part of what you can do with Skript, but I hope it helped you get your feet wet. To learn more, check out the [Core Concepts](broken-reference/) pages for more in-depth tutorials. You should also become familiar with the [official docs](https://docs.skriptlang.org/index.html), or with the [SkriptHub docs](https://skripthub.net/docs/) if you prefer those. They'll help you tremendously.
249
258
250
259
Happy Skripting!
260
+
261
+
{% hint style="danger" %}
262
+
If you had trouble following along, or didn't like this tutorial for some reason, please either message me on Discord at Sovde#0001, or open an issue on the github repository for this site.
0 commit comments