Discuss Scratch

Advantage_coding
Scratcher
90 posts

How to use the "My blocks" feature?

I want to know how to use the “My blocks” feature? I feel like it could really help me, but I just don't know how!
Any help appreciated al lot
DifferentDance8
Scratcher
1000+ posts

How to use the "My blocks" feature?

Advantage_coding wrote:

I want to know how to use the “My blocks” feature? I feel like it could really help me, but I just don't know how!
Any help appreciated al lot
Thanks for asking!

The my blocks section is essentially a category where you decide (for your project) what blocks exactly do you want to put there. It's like a sandbox but for scratch.

As an example, say you wanted to make a project. In this project, you would want your player to jump.
You could do:

whenwhatever you want your key to jump to bekeypressedchangeyby5 5 is an example, you can set it to how high you want to jump.wait1secs like i said, also an examplechangeyby-5 5 is how high you jump in this example. JUST MAKE SURE YOU SET IT TO THE NEGATIVE OF THE JUMP HEIGHT!

But that takes up space, so you can just package it in a block (in this example, called “jump”)

definejumpifkeylike i said, your jump keypressed?thenchangeyby5wait1secschangeyby-5 all these comments are the same as the last example

And then do this to let your player jump:

whenclicked or whenever you want your player to jumpforeverjump

And that is essentially it for now.
Advantage_coding
Scratcher
90 posts

How to use the "My blocks" feature?

Thank you so much! I have a way better understanding now
deck26
Scratcher
1000+ posts

How to use the "My blocks" feature?

https://en.scratch-wiki.info/wiki/My_Blocks

As well as tidying up code and making it more readable custom blocks have advantages.

- a custom block called by a sprite or clone is only run by that sprite/clone whereas all clones will act on a broadcast which would be another way to split code

- you can use the ‘no screen refresh’ option for speed

- you can pass parameters so eg you can draw a circle at a specified location and a specified size just by entering the correct values in a the custom block call
Advantage_coding
Scratcher
90 posts

How to use the "My blocks" feature?

what do you mean by ‘no screen refresh’?
RT_Borg
Scratcher
1000+ posts

How to use the "My blocks" feature?

Advantage_coding wrote:

what do you mean by ‘no screen refresh’?
Hi Advantage_coding,

Many of the blocks in scratch cause a script to pause for 1/30 of a second to redraw. For example, if you do a series of moves or costume changes, you typically want to see each change on the screen before then next one.

But sometimes you want to do a lot of operations all at once, without slowing down or having the player see. An example would be testing whether a moving sprite is colliding with a wall, so it can change directions. You might move forward, test and discover you're now touching (inside) the wall, and then quickly undo the move (move back in the opposite direction). You don't want the player to see that test and maybe back out of a collision, so you'd want to do it “without screen refresh.”

When you make a custom block, there's a checkbox where you can choose “without screen refresh” for the block.

– RT_Borg

Last edited by RT_Borg (Sept. 2, 2022 08:02:24)

Advantage_coding
Scratcher
90 posts

How to use the "My blocks" feature?

thank u!
KaaBEL_sk
Scratcher
100+ posts

How to use the "My blocks" feature?

I would also mention advantage of using stop this script in my blocks.
stopthis script

Sometimes a script inside loop requires to stop before the end of loop, but cotinue other code. Or it can be used as end the loop instead of puting more conditions in repeat until, there can be anywhere in the script if with stop this script.

I also use my blocks for comments (as I saw somewhere else). Those are composed in the sript, and stay even after backpacking the script.
define (comment)//here's stuff commented
STAR_BRUH
Scratcher
1 post

How to use the "My blocks" feature?

hi
isaacxcode
Scratcher
2 posts

How to use the "My blocks" feature?

Advantage_coding wrote:

I want to know how to use the “My blocks” feature? I feel like it could really help me, but I just don't know how!
Any help appreciated al lot

To make it simple, when you make a block you get two things:

define

and in the my blocks section you will see another block.

Now, the block that you see in the my blocks section, is what will trigger what is inside of the Define “Your block name”

define

For example, in the Define block, if I were to put in a change x by 10
whenclicked
forever
Theblock

So basically what this does is "When the flag Is clicked, forever, trigger your block. Inside of the block is a change x by 10. So you will forever change x by 10.

Last edited by isaacxcode (April 7, 2024 15:26:46)

MineTurte
Scratcher
1000+ posts

How to use the "My blocks" feature?

isaacxcode wrote:

Advantage_coding wrote:

I want to know how to use the “My blocks” feature? I feel like it could really help me, but I just don't know how!
Any help appreciated al lot

To make it simple, when you make a block you get two things:

define

and in the my blocks section you will see another block.

Now, the block that you see in the my blocks section, is what will trigger what is inside of the Define “Your block name”

define

For example, in the Define block, if I were to put in a change x by 10
whenclicked
forever
Theblock

So basically what this does is "When the flag Is clicked, forever, trigger your block. Inside of the block is a change x by 10. So you will forever change x by 10.
Please don't necropost; especially when it already seems as if this topic was resolved. Thanks!

Necroposting is when you post on an old topic either not adding anything or adding irrelevant information. In your case you were just saying what was already said.

Last edited by MineTurte (April 7, 2024 15:30:13)

wajidtheghost7
Scratcher
2 posts

How to use the "My blocks" feature?

there are 3 options in the my blocks window the add an input (number or text) and add an input (boolean) and add a label there is also a run without screen refresh option
TheNoisyNoisy
Scratcher
100+ posts

How to use the "My blocks" feature?

just so you know boolean is barely ever used lol
LukaTang
Scratcher
3 posts

How to use the "My blocks" feature?

Advantage_coding wrote:

I want to know how to use the “My blocks” feature? I feel like it could really help me, but I just don't know how!
Any help appreciated al lot
hi, @Advantage_coding ,

my blocks are created by yourself, when you created it, it usually pops up a define block
for example:
define
you can change what is in the blank space above by typing in the block(editing block mode)
a simple understanding of my blocks is when the green flag is clicked, the code starts running, but when it runs to the one of the my blocks, it will find the define block, and do what is in the define block. But when the define block's code is finished, it goes back to the main script where the my block is, and continues what is under
example code:
definesay_hisayhifor2secswhenclickedsay_hi

at the end, the sprite will say “hi”




From: @LukaTang you can ask me on my profile if needed in the future

Powered by DjangoBB