Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Does anyone know how to use the code my blocks Idk how to create one
- BPMGbest
-
14 posts
Does anyone know how to use the code my blocks Idk how to create one
I try to create a block in my blocks but Idk what it does or how to make it properly
I can't make it work
I can't make it work
define
- Met4Knight
-
100+ posts
Does anyone know how to use the code my blocks Idk how to create one
basically, the my block thing lets you create a block by putting blocks in the definition section, here's an exemple
in this exemple, the height input takes the value that is in the input slot, that is, 10, so it will run the script under the hat block and every time that there is a height reporter in the script, the valye used will be 10
define jump (height)
repeat (height)
change y by (1)
end
repeat (height)
change y by (-1)
end
when green flag clicked
jump (10)
in this exemple, the height input takes the value that is in the input slot, that is, 10, so it will run the script under the hat block and every time that there is a height reporter in the script, the valye used will be 10
- K4ffekoppen
-
44 posts
Does anyone know how to use the code my blocks Idk how to create one
It can be used like a shortcut in order to not have to repeat long codes over and over again if you plan on using it several times.
So for instance if I want a character to do several things everytime I can make a custom block.
I can make a block called “Lava”, I have a game with lava in it in several different places, when my character touches the lava I want him to slide down, change x by 5 and say “Oh no”.
That block “Lava” holds all that code, so I can just insert “Lava” all the different times that I want my character to slide down, change x by 5 and say “Oh no” instead of repeating that code over and over.
So it's a way to keep things more tidy.
That's how I'd describe it, I haven't used it much though so someone else can correct me otherwise.
So for instance if I want a character to do several things everytime I can make a custom block.
I can make a block called “Lava”, I have a game with lava in it in several different places, when my character touches the lava I want him to slide down, change x by 5 and say “Oh no”.
That block “Lava” holds all that code, so I can just insert “Lava” all the different times that I want my character to slide down, change x by 5 and say “Oh no” instead of repeating that code over and over.
So it's a way to keep things more tidy.
That's how I'd describe it, I haven't used it much though so someone else can correct me otherwise.
- Connerfurr13
-
49 posts
Does anyone know how to use the code my blocks Idk how to create one
define ez
say [This is easy!] for (2) secs
when green flag clicked
ez
[scratchblocks]
- BPMGbest
-
14 posts
Does anyone know how to use the code my blocks Idk how to create one
OK now I'm starting to understand but what does
(Whateverthis is do)
- K4ffekoppen
-
44 posts
Does anyone know how to use the code my blocks Idk how to create one
Do you mean variables?
- han614698
-
1000+ posts
Does anyone know how to use the code my blocks Idk how to create one
Variables work basically as memorization.
So if you do this,
So if you do this,
set [my variable v] to [10]your sprite will move 10 steps.
move (my variable) steps
- ametrine_
-
1000+ posts
Does anyone know how to use the code my blocks Idk how to create one
if you're talking about parameters (the variables inside the custom blocks), here's an example of how they work: OK now I'm starting to understand but what does(Whateverthis is do)
move (5) // this sets the "amount" parameter to 5 when we run the block
define move (amount)
move (amount) steps // since we ran the block with a value of 5 in the "amount" parameter, it'll move 5 steps
- cheekybubba5
-
100+ posts
Does anyone know how to use the code my blocks Idk how to create one
Here is my explanation:
Custom blocks, besides being able to repeat scripts without having to copy and paste the, have a “Run without screen refresh” check box when creating it.
This is especially helpful when running the script all at once without it animating.
Once you get more advanced into real math classes, you'll see how they work. In a simple explanation, they store a data that can then be altered and manipulated.
Custom blocks, besides being able to repeat scripts without having to copy and paste the, have a “Run without screen refresh” check box when creating it.
This is especially helpful when running the script all at once without it animating.
Once you get more advanced into real math classes, you'll see how they work. In a simple explanation, they store a data that can then be altered and manipulated.
- BPMGbest
-
14 posts
Does anyone know how to use the code my blocks Idk how to create one
if you're talking about parameters (the variables inside the custom blocks), here's an example of how they work: OK now I'm starting to understand but what does(Whateverthis is do)move (5) // this sets the "amount" parameter to 5 when we run the block
define move (amount)
move (amount) steps // since we ran the block with a value of 5 in the "amount" parameter, it'll move 5 steps
I Do not understand properly bc I tried using the my blocks it doesn't really end up working
- ametrine_
-
1000+ posts
Does anyone know how to use the code my blocks Idk how to create one
what wasn't working about them? I Do not understand properly bc I tried using the my blocks it doesn't really end up working
- BPMGbest
-
14 posts
Does anyone know how to use the code my blocks Idk how to create one
what wasn't working about them? I Do not understand properly bc I tried using the my blocks it doesn't really end up working
It was not doing anything properly it was doing the code but not when I press the green flag which is when it's supposed to activate I had to ‘see inside’ and click the code with
define
- ametrine_
-
1000+ posts
Does anyone know how to use the code my blocks Idk how to create one
can you share an example project so i can see what's happening? It was not doing anything properly it was doing the code but not when I press the green flag which is when it's supposed to activate I had to ‘see inside’ and click the code withdefine
- BPMGbest
-
14 posts
Does anyone know how to use the code my blocks Idk how to create one
can you share an example project so i can see what's happening? It was not doing anything properly it was doing the code but not when I press the green flag which is when it's supposed to activate I had to ‘see inside’ and click the code withdefine
I made the project and the code is:
define jump(height)
move (10) steps
wait (1) secs
turn cw (15) degrees
The red jump that says height in orange below this is meant to be the my blocks code but I don't know how to put it as my blocks
The other part of the code was
when green flag clicked
jump(height)
The link for the project is: https://scratch.mit.edu/projects/1093308410/
Last edited by BPMGbest (Nov. 9, 2024 00:02:23)
- bsteichman
-
500+ posts
Does anyone know how to use the code my blocks Idk how to create one
your confusion is where the input should be placed…
basically the reporters pass a number through.
an easy example:
when you run that block, it replaces
jump (height ::custom) ::customis incorrect because we have not told the computer what “height” is.
basically the reporters pass a number through.
an easy example:
define set variable to (a) + (b)now if i run the code as follows:
set [example v] to ((a) + (b))
set variable to (2) + (4) ::customit will set our example variable to 6, you are basically making filler values that you can replace later!
when you run that block, it replaces
set [example v] to ((a::custom) + (b::custom))with
set [example v] to ((2) + (4))why did it replace the ‘a’ with a 2? because you put a 2 in the ‘a’ slot!
Last edited by bsteichman (Nov. 9, 2024 07:07:24)
- THEIMPORTANT
-
100+ posts
Does anyone know how to use the code my blocks Idk how to create one
basically a define block if a function. you can add inputs like so
this will move the sprite 5 blocks. you can change the value to anything. Also this is not the only place it is used.
define move(amount)
move (amount) steps
move 5 steps
this will move the sprite 5 blocks. you can change the value to anything. Also this is not the only place it is used.
Last edited by THEIMPORTANT (Nov. 10, 2024 04:36:20)
- Discussion Forums
- » Help with Scripts
-
» Does anyone know how to use the code my blocks Idk how to create one