Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to use the "My blocks" feature?
        ![[RSS Feed] [RSS Feed]](//cdn.scratch.mit.edu/scratchr2/static/__5b3e40ec58a840b41702360e9891321b__//djangobb_forum/img/feed-icon-small.png)  
- Advantage_coding
- 
                             Scratcher 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





                        
                        
                    Any help appreciated al lot






- DifferentDance8
- 
                             Scratcher Scratcher
1000+ 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!Thanks for asking!
Any help appreciated al lot
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:
when [whatever you want your key to jump to be v] key pressed
change y by (5) // 5 is an example, you can set it to how high you want to jump.
wait (1) secs // like i said, also an example
change y by (-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”)
define jump
if <key [like i said, your jump key v] pressed?> then
change y by (5)
wait (1) secs
change y by (-5) // all these comments are the same as the last example
end
And then do this to let your player jump:
when green flag clicked // or whenever you want your player to jump
forever
jump :: custom blocks
end
And that is essentially it for now.
- Advantage_coding
- 
                             Scratcher Scratcher
90 posts
How to use the "My blocks" feature?
Thank you so much! I have a way better understanding now 
                        
                        
                    
- deck26
- 
                             Scratcher 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
                        
                        
                    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 Scratcher
90 posts
How to use the "My blocks" feature?
what do you mean by  ‘no screen refresh’?
                        
                        
                    
- RT_Borg
- 
                             Scratcher Scratcher
1000+ posts
How to use the "My blocks" feature?
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)
- KaaBEL_sk
- 
                             Scratcher Scratcher
100+ posts
How to use the "My blocks" feature?
I would also mention advantage of using stop this script in my blocks.
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.
                        
                        
                    stop [this script v]
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]
- isaacxcode
- 
                             Scratcher Scratcher
2 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
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
when green flag clicked
forever
end
(The block)
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 Scratcher
1000+ posts
How to use the "My blocks" feature?
Please don't necropost; especially when it already seems as if this topic was resolved. Thanks!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 10when green flag clickedforever
end(The block)
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.
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 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 Scratcher
100+ posts
How to use the "My blocks" feature?
just so you know boolean is barely ever used lol
                        
                        
                    - LukaTang
- 
                             Scratcher Scratcher
6 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!hi, @Advantage_coding ,
Any help appreciated al lot
my blocks are created by yourself, when you created it, it usually pops up a define block
for example:
defineyou 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:
define say_hi
say [hi] for (2) secs
when green flag clicked
say_hi
at the end, the sprite will say “hi”
From: @LukaTang you can ask me on my profile if needed in the future
- Discussion Forums
- » Help with Scripts
- 
            » How to use the "My blocks" feature? ![[RSS Feed] [RSS Feed]](//cdn.scratch.mit.edu/scratchr2/static/__5b3e40ec58a840b41702360e9891321b__//djangobb_forum/img/feed-icon-small.png)  
 
            ![[RSS Feed] [RSS Feed]](http://cdn.scratch.mit.edu/scratchr2/static/__5b3e40ec58a840b41702360e9891321b__//djangobb_forum/img/feed-icon-small.png)












