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: introduction/the-basics.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ Much better. Let's add some class into this command though, and tell the player
78
78
command /food:
79
79
trigger:
80
80
give 2 steak to player
81
-
send "You receieved some food!" to player
81
+
send "You received some food!" to player
82
82
```
83
83
84
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.
@@ -126,10 +126,10 @@ command /food:
126
126
trigger:
127
127
if player is an op:
128
128
give 2 golden apples to player
129
-
send "You receieved some food!" to player
129
+
send "You received some food!" to player
130
130
else:
131
131
give 2 steak to player
132
-
send "You receieved some food!" to player
132
+
send "You received some food!" to player
133
133
```
134
134
135
135
See how the indentation shows what it supposed to run? If the player is an op, we know to run that indented code after the `if`. If they aren't, we can jump straight to the `else` and run that code instead. This is called an `if/else`, and is a basic concept across nearly every programming language. It's the most basic way of controlling what code gets run, called `control flow` in programming jargon.
@@ -147,7 +147,7 @@ command /food:
147
147
give 2 golden apples to player
148
148
else:
149
149
give 2 steak to player
150
-
send "You receieved some food!" to player
150
+
send "You received some food!" to player
151
151
```
152
152
153
153
Un-indenting the send pulls it out of the `else`, meaning it will be run whether the player is op or not. The give is a bit more complicated. Honestly, this code is fine, it's very little duplication and wouldn't be that bad. But let's keep going for the sake of teaching you about variables.
@@ -162,7 +162,7 @@ command /food:
162
162
else:
163
163
set {_item} to 2 steak
164
164
give {_item} to player
165
-
send "You receieved some food!" to player
165
+
send "You received some food!" to player
166
166
```
167
167
168
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.
@@ -181,7 +181,7 @@ command /food:
181
181
else:
182
182
set {_item} to 2 steak
183
183
give {_item} to player
184
-
send "You receieved %{_item}%!" to player
184
+
send "You received %{_item}%!" to player
185
185
```
186
186
187
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).
0 commit comments