Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » More Blocks?
- turkey3_test
-
Scratcher
1000+ posts
More Blocks?
More blocks are custom blocks, and the best way to explain it is visually.
define jump //name of the blockYou should also check out on the Wiki Custom Blocks.
repeat (10)
change y by (5)
end
repeat (10)
change y by (-10)
end
when gf clicked
jump //you can do this instead of writing the whole script above
- justin_lau
-
Scratcher
43 posts
More Blocks?
More blocks are custom blocks, and the best way to explain it is visually.define jump //name of the blockYou should also check out on the Wiki Custom Blocks.
repeat (10)
change y by (5)
end
repeat (10)
change y by (-10)
end
when gf clicked
jump //you can do this instead of writing the whole script above
So, how is it different from Broadcast blocks?
- turkey3_test
-
Scratcher
1000+ posts
More Blocks?
There are a few differences. What I have above is only a simple type. Parameters can be inserted into custom blocks as such:More blocks are custom blocks, and the best way to explain it is visually.define jump //name of the blockYou should also check out on the Wiki Custom Blocks.
repeat (10)
change y by (5)
end
repeat (10)
change y by (-10)
end
when gf clicked
jump //you can do this instead of writing the whole script above
So, how is it different from Broadcast blocks?
define jump (height) pixelsSo you can customize the value by changing the parameters. Also, only one broadcast received script can be running in the sprite at once, but with custom blocks the same custom block, or “procedure”, can run in many scripts simultaneously,
repeat (round ((height) / (5)))
change y by (5)
end
repeat (round ((height) / (5)))
change y by (-5)
end
when gf clicked
jump (50) pixels
jump (100) pixels
jump (30) pixels
- justin_lau
-
Scratcher
43 posts
More Blocks?
I
I still don't get it
There are a few differences. What I have above is only a simple type. Parameters can be inserted into custom blocks as such:More blocks are custom blocks, and the best way to explain it is visually.define jump //name of the blockYou should also check out on the Wiki Custom Blocks.
repeat (10)
change y by (5)
end
repeat (10)
change y by (-10)
end
when gf clicked
jump //you can do this instead of writing the whole script above
So, how is it different from Broadcast blocks?define jump (height) pixelsSo you can customize the value by changing the parameters. Also, only one broadcast received script can be running in the sprite at once, but with custom blocks the same custom block, or “procedure”, can run in many scripts simultaneously,
repeat (round ((height) / (5)))
change y by (5)
end
repeat (round ((height) / (5)))
change y by (-5)
end
when gf clicked
jump (50) pixels
jump (100) pixels
jump (30) pixels
I still don't get it
- ErnieParke
-
Scratcher
1000+ posts
More Blocks?
@justin_lau:
It's okay. When I first learned about parameters, I didn't get it as well.
Now, let's take a look back at Turkey3's script (with a few touches):
The variable height is just like any variable. When you say [jump (50) pixels] you're setting height to 50. When you say [jump (77) pixels], you're setting it to 77. Do you see?
When you say [jump (50) pixels], you're also running the code beneath the block. So when you say [jump (50) pixels], you're saying jump up 50 pixels! That's done by:
Where did the height variable go? When we ran [jump (50) pixels], we set height to 50. So it's in the script. Then we change y by 50, and change it by -50 to finish our jump.
Any questions?
Explaining,
ErnieParke
It's okay. When I first learned about parameters, I didn't get it as well.

Now, let's take a look back at Turkey3's script (with a few touches):
define jump (height) pixels
repeat (height)
change y by (1)
end
repeat (height)
change y by (-1)
end
when gf clicked
jump (50) pixels
The variable height is just like any variable. When you say [jump (50) pixels] you're setting height to 50. When you say [jump (77) pixels], you're setting it to 77. Do you see?
When you say [jump (50) pixels], you're also running the code beneath the block. So when you say [jump (50) pixels], you're saying jump up 50 pixels! That's done by:
repeat (50)
change y by (1)
end
repeat (50)
change y by (-1)
end
Where did the height variable go? When we ran [jump (50) pixels], we set height to 50. So it's in the script. Then we change y by 50, and change it by -50 to finish our jump.
Any questions?
Explaining,
ErnieParke
- 1234abcdcba4321
-
Scratcher
1000+ posts
More Blocks?
Also, blocks don't carry between sprites. (I wish they did…)
- justin_lau
-
Scratcher
43 posts
More Blocks?
Th
@justin_lau:Thks
It's okay. When I first learned about parameters, I didn't get it as well.
Now, let's take a look back at Turkey3's script (with a few touches):define jump (height) pixels
repeat (height)
change y by (1)
end
repeat (height)
change y by (-1)
end
when gf clicked
jump (50) pixels
The variable height is just like any variable. When you say [jump (50) pixels] you're setting height to 50. When you say [jump (77) pixels], you're setting it to 77. Do you see?
When you say [jump (50) pixels], you're also running the code beneath the block. So when you say [jump (50) pixels], you're saying jump up 50 pixels! That's done by:repeat (50)
change y by (1)
end
repeat (50)
change y by (-1)
end
Where did the height variable go? When we ran [jump (50) pixels], we set height to 50. So it's in the script. Then we change y by 50, and change it by -50 to finish our jump.
Any questions?
Explaining,
ErnieParke
- Discussion Forums
- » Questions about Scratch
-
» More Blocks?
