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
Copy file name to clipboardExpand all lines: core-concepts/lists/README.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,7 @@
1
+
---
2
+
description: In Progress
3
+
---
4
+
1
5
# Lists
2
6
3
7
Skript has a very powerful variable variant called lists which allow you to store multiple values and access them as a group, loop through them, or just get them by themselves.
Talk about the weird ways index serialization works, maybe talk about how to tie two values together with list index (block type/location, etc). eg: why you can't just assume `stone` and `%1 stone%` will be the same index, why locations can't be taken back out of indices, etc
Copy file name to clipboardExpand all lines: core-concepts/variables/README.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Variables
2
2
3
-
Variables are a key component in any useful programming language, and Skript is no exception. They allow you to store data, move data around, make code readable, and much more. 
3
+
Variables are a key component in any useful programming language, and Skript is no exception. They allow you to store data, move data around, make code readable, and much more.
4
4
5
5
At their core, variables are a label for information. If you've taken algebra in math, you probably understand the concept. Instead of using an actual number, you use `x` or `y` as a stand-in for an unknown or changing number. This is the same concept as variables in programming. Variables are representations, or stand-ins, of unknown or changing data.
6
6
@@ -14,9 +14,9 @@ set {_variable} to 2
14
14
set {hey, what's going on} to "not much, what about you?"
15
15
```
16
16
17
-
Variables can have nearly any name you like. They have have spaces, dashes, symbols, whatever. You can put the whole Bee Movie script into a variable name, if you so choose. There are a few special ways to name variables though. 
17
+
Variables can have nearly any name you like. They have have spaces, dashes, symbols, whatever. You can put the whole Bee Movie script into a variable name, if you so choose. There are a few special ways to name variables though.
18
18
19
-
By default, variables are `global`, which means they can be seen and changed by any part of your script. Often we want variables to exist only in a small section of script, which is achieved by `local` variables, with begin with `_`, like `{_variable}`. We'll get further into this difference in the [Global and Local page](global-and-local.md). 
19
+
By default, variables are `global`, which means they can be seen and changed by any part of your script. Often we want variables to exist only in a small section of script, which is achieved by `local` variables, with begin with `_`, like `{_variable}`. We'll get further into this difference in the [Global and Local page](global-and-local.md).
20
20
21
21
### Using Variables
22
22
@@ -33,7 +33,7 @@ command /math <number>:
33
33
send "%10 * {_x}^2 + 3 * {_x} + 4%"
34
34
```
35
35
36
-
 That's much easier to read! Plus, it means if we need {\_x} again later in the command, we have it ready to use, without having to retype it. And if we want to change `7` to `6`, we only have to change 1 number instead of 2 or more. Be careful with using too many variables, though. If overused, they can make code more cluttered and messy than necessary:
36
+
That's much easier to read! Plus, it means if we need {\_x} again later in the command, we have it ready to use, without having to retype it. And if we want to change `7` to `6`, we only have to change 1 number instead of 2 or more. Be careful with using too many variables, though. If overused, they can make code more cluttered and messy than necessary:
37
37
38
38
```applescript
39
39
# questionable overuse of variables
@@ -46,7 +46,7 @@ command /math <number>:
46
46
47
47
### Using Variables to Store Data
48
48
49
-
Global variables in particular are great for storing and transferring data. Here we'll use a very basic `/home` command system to demonstrate. 
49
+
Global variables in particular are great for storing and transferring data. Here we'll use a very basic `/home` command system to demonstrate.
50
50
51
51
```applescript
52
52
command /sethome:
@@ -58,11 +58,11 @@ command /home:
58
58
teleport player to {home}
59
59
```
60
60
61
-
Perfect, right? We save the player's location to a variable, and then when they want to go home, we can just use the variable to look up the current location the home is set to. 
61
+
Perfect, right? We save the player's location to a variable, and then when they want to go home, we can just use the variable to look up the current location the home is set to.
62
62
63
63
Well, this is only partially correct. You see, since global variables are, in fact, global, there's only one of them at any time. So if someone else comes along and does `/sethome`, the `{home}` variable now has their home location, and if you use `/home`, you're getting teleported to their home instead!
64
64
65
-
To solve this, we need to make the variable unique for each player. The best method to do this is to use the player's uuid as part of the variable name. If you use just `player` or `player's name`, you run the risk of the data no longer being useful when the player changes their name. This is why it's always recommended to use uuids, or enable the config option `use player UUIDs in variable names`, which is explained [here](../../auxiliary-guides/useful-config-options.md).
65
+
To solve this, we need to make the variable unique for each player. The best method to do this is to use the player's uuid as part of the variable name. If you use just `player` or `player's name`, you run the risk of the data no longer being useful when the player changes their name. This is why it's always recommended to use uuids, or enable the config option `use player UUIDs in variable names`, which is explained [here](../../unfinished/auxiliary-guides/useful-config-options.md).
66
66
67
67
```applescript
68
68
command /sethome:
@@ -74,7 +74,7 @@ command /home:
74
74
teleport player to {home::%player's uuid%}
75
75
```
76
76
77
-
Now each player has a unique home variable that we can get using their uuid. Note the use of `::` in the variable name. This is used to create list variables, which are explained [here](list-basics.md), with a more in- depth explanation [here](../lists/). The main thing to understand is that using `::` means we have much more power over the variable. We can delete all homes at once, we can easily see all the homes that are set, and much more. 
77
+
Now each player has a unique home variable that we can get using their uuid. Note the use of `::` in the variable name. This is used to create list variables, which are explained [here](list-basics.md), with a more in- depth explanation [here](../lists/). The main thing to understand is that using `::` means we have much more power over the variable. We can delete all homes at once, we can easily see all the homes that are set, and much more.
78
78
79
79
```applescript
80
80
# clear all homes
@@ -84,4 +84,4 @@ clear {home::*}
84
84
broadcast {home::*}
85
85
```
86
86
87
-
That's all for the basics. The next section, [Global and Local](global-and-local.md), will explain more about the differences between global variables and local ones, when you should use them, and what benefits each has. 
87
+
That's all for the basics. The next section, [Global and Local](global-and-local.md), will explain more about the differences between global variables and local ones, when you should use them, and what benefits each has.
Copy file name to clipboardExpand all lines: introduction/the-basics.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ We want a code that fills the player's hunger bar, but we don't know what to wri
39
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
40
{% endhint %}
41
41
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.
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](../unfinished/syntax-types/reading-syntax.md), but it's pretty simple once you know how. For now, we'll just look at the example.
43
43
44
44
```applescript
45
45
set the player's food level to 10
@@ -202,7 +202,7 @@ set {_tool-text} to "%player's tool%"
202
202
203
203
### Using Events
204
204
205
-
We've been using a command all this time, but events are another extremely useful way to trigger code in Skript. Events are things that happen when certain, well, events happen in the game. Say the player jumps. There's an event for that. Say a furnace burns a piece of coal. There's an event for that. Say a sheep regrows its wool. There's an event for that. You can see all the events at [https://docs.skriptlang.org/events.html](https://docs.skriptlang.org/events.html). You can also learn more about them in the[ Events page](../syntax-types/events.md).
205
+
We've been using a command all this time, but events are another extremely useful way to trigger code in Skript. Events are things that happen when certain, well, events happen in the game. Say the player jumps. There's an event for that. Say a furnace burns a piece of coal. There's an event for that. Say a sheep regrows its wool. There's an event for that. You can see all the events at [https://docs.skriptlang.org/events.html](https://docs.skriptlang.org/events.html). You can also learn more about them in the[ Events page](../unfinished/syntax-types/events.md).
206
206
207
207
Events are kind of like commands in that they're never indented. Commands and events always start all the way to the left. Since we've been giving players food, let's use an `on consume` event:
Copy file name to clipboardExpand all lines: readme/syntax-overview.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ I will warn you, this is a very long page. Feel free to use the right-side bar t
14
14
15
15
## Crash Course in Reading Syntax
16
16
17
-
You may have looked at the Skript docs and been very confused on how to turn that long string of words and symbols into actual code. The docs can be a bit daunting if you don't know the rules for how to read them. Here's a little crash course, but if you want more detail, head over to [Reading Syntax](../syntax-types/reading-syntax.md).
17
+
You may have looked at the Skript docs and been very confused on how to turn that long string of words and symbols into actual code. The docs can be a bit daunting if you don't know the rules for how to read them. Here's a little crash course, but if you want more detail, head over to [Reading Syntax](../unfinished/syntax-types/reading-syntax.md).
0 commit comments