Skip to content

Commit 6499931

Browse files
sovdeethgitbook-bot
authored andcommitted
GITBOOK-52: No subject
1 parent b4231b1 commit 6499931

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

introduction/the-basics.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Much better. Let's add some class into this command though, and tell the player
7878
command /food:
7979
trigger:
8080
give 2 steak to player
81-
send "You receieved some food!" to player
81+
send "You received some food!" to player
8282
```
8383

8484
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:
126126
trigger:
127127
if player is an op:
128128
give 2 golden apples to player
129-
send "You receieved some food!" to player
129+
send "You received some food!" to player
130130
else:
131131
give 2 steak to player
132-
send "You receieved some food!" to player
132+
send "You received some food!" to player
133133
```
134134

135135
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:
147147
give 2 golden apples to player
148148
else:
149149
give 2 steak to player
150-
send "You receieved some food!" to player
150+
send "You received some food!" to player
151151
```
152152

153153
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:
162162
else:
163163
set {_item} to 2 steak
164164
give {_item} to player
165-
send "You receieved some food!" to player
165+
send "You received some food!" to player
166166
```
167167

168168
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:
181181
else:
182182
set {_item} to 2 steak
183183
give {_item} to player
184-
send "You receieved %{_item}%!" to player
184+
send "You received %{_item}%!" to player
185185
```
186186

187187
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

Comments
 (0)