Discuss Scratch

BladiPetrov
Scratcher
100+ posts

Showing how to use Custom Blocks

So in this post I will be showing how to use custom blocks! (because many people don't know what they do). We'll start off with the basics.

A custom block is a block you can make it do whatever you want. To make it do something, use the “define” block. You can try anything:
define my custom block
repeat (pick random (1) to (15)) // Turns left 12.5 a random amount of times from 1 to 15 times
turn left (12.5) degrees
end
repeat (10) // Moves 10 times a random amount of pixels EACH FRAME from 1px to 5px
move (pick random (1) to (5)) steps
end

my custom block // This runs the code in the define block
But this is kinda boring. That's why we got inputs!!! The inputs are basically mini-variables for each time the custom block runs. It can't be used in ANYWHERE except the define script. We got 2 inputs in Scratch 3 (3 in Scratch 2). The text-numerical input, the boolean input, and the label. The label is just to continue writing the name. Let's see what we can do. We'll start with the text-numerical input, specifically numerical:
define my new custom block with (input)
say [Hello!] for (input) secs // This will say "Hello!" for the amount of seconds the input says

my new custom block with (3) // This means it will say "Hello!" for 3 seconds.
Now the text:
define say [input]
say (input) for (2) secs // This will say what the input says for 2 secs

say [Anything] // This will make it say "Anything" for 2 seconds
And now, the boolean. The boolean is a TRUE/FALSE input. You can incrust any block with the <> shape:
define the boolean block <this is true?>
if <this is true?> then // The input works like a boolean itself. You just put it there
say [It's true!]
else // If the input <this is true?> is true, then it will say "It's true!". If it isn't it says "It's false!"
say [It's false!]
end

the boolean block <> // If you don't put anything, it's always FALSE
the boolean block <not<>> // If you only put a not<>, it's always TRUE
the boolean block <(my variable) = (2)> // If "my variable" is 2, the input will be TRUE. If it's not 2, the input will be FALSE.
Now, for the triple finish! All at once!
define TRIPLE FINISH (number) [text] <boolean>
if <boolean> then // If the boolean input is TRUE, run code. If it's FALSE, stop all
say (text) for (number) secs // The boolean was true. Says the text input for the number input amount of seconds
else
stop [all v]
end

TRIPLE FINISH (5) [TRIPLE] <not<>> // The boolean will always be TRUE. If it's TRUE (always) say "TRIPLE" for 5 seconds.
Hope I helped. Writing this took way too long. For any questions, don't worry asking
Cuphead1234567123
Scratcher
3 posts

Showing how to use Custom Blocks

if <answer=yes> then
emotion happy

end
Cuphead1234567123
Scratcher
3 posts

Showing how to use Custom Blocks

say [] for (infinity) secs
if <dog= wag tail> then
change emotion "normal" "happy"
else
change emotion "any" "normal"
TenderFeat
Scratcher
1 post

Showing how to use Custom Blocks

How do i make the diamond block

Last edited by TenderFeat (Jan. 15, 2025 19:14:12)

BladiPetrov
Scratcher
100+ posts

Showing how to use Custom Blocks

TenderFeat wrote:

How do i make the diamond block
Diamond block? What diamond block?
AdiyanTsembelev
Scratcher
1 post

Showing how to use Custom Blocks

stop all sound
CoolWolfFurry
Scratcher
6 posts

Showing how to use Custom Blocks

define hii
(scratch so cool:3)

Powered by DjangoBB