Discuss Scratch

BPMGbest
Scratcher
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
define
Met4Knight
Scratcher
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
definejumpheightrepeatheightchangeyby1repeatheightchangeyby-1whenclickedjump10

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
New Scratcher
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.
Connerfurr13
Scratcher
47 posts

Does anyone know how to use the code my blocks Idk how to create one

defineezsayThis is easy!for2secs

whenclickedezscratchblocks
BPMGbest
Scratcher
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
Whateverthisisdo
K4ffekoppen
New Scratcher
44 posts

Does anyone know how to use the code my blocks Idk how to create one

Do you mean variables?
han614698
Scratcher
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,
setmy variableto10movemyvariablesteps
your sprite will move 10 steps.
ametrine_
Scratcher
1000+ posts

Does anyone know how to use the code my blocks Idk how to create one

BPMGbest wrote:

OK now I'm starting to understand but what does
Whateverthisisdo
if you're talking about parameters (the variables inside the custom blocks), here's an example of how they work:

move5 this sets the "amount" parameter to 5 when we run the blockdefinemoveamountmoveamountsteps since we ran the block with a value of 5 in the "amount" parameter, it'll move 5 steps
cheekybubba5
Scratcher
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.
30elkinsw
Scratcher
1 post

Does anyone know how to use the code my blocks Idk how to create one

Hi
BPMGbest
Scratcher
14 posts

Does anyone know how to use the code my blocks Idk how to create one

ametrine_ wrote:

BPMGbest wrote:

OK now I'm starting to understand but what does
Whateverthisisdo
if you're talking about parameters (the variables inside the custom blocks), here's an example of how they work:

move5 this sets the "amount" parameter to 5 when we run the blockdefinemoveamountmoveamountsteps 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_
Scratcher
1000+ posts

Does anyone know how to use the code my blocks Idk how to create one

BPMGbest wrote:

I Do not understand properly bc I tried using the my blocks it doesn't really end up working
what wasn't working about them?
BPMGbest
Scratcher
14 posts

Does anyone know how to use the code my blocks Idk how to create one

ametrine_ wrote:

BPMGbest wrote:

I Do not understand properly bc I tried using the my blocks it doesn't really end up working
what wasn't working about them?

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_
Scratcher
1000+ posts

Does anyone know how to use the code my blocks Idk how to create one

BPMGbest wrote:

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
can you share an example project so i can see what's happening?
BPMGbest
Scratcher
14 posts

Does anyone know how to use the code my blocks Idk how to create one

ametrine_ wrote:

BPMGbest wrote:

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
can you share an example project so i can see what's happening?


I made the project and the code is:
definejumpheightmove10stepswait1secsturn15degrees

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
whenclickedjumpheight

The link for the project is: https://scratch.mit.edu/projects/1093308410/

Last edited by BPMGbest (Nov. 9, 2024 00:02:23)

bsteichman
Scratcher
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…
jumpheight
is incorrect because we have not told the computer what “height” is.

basically the reporters pass a number through.

an easy example:
definesetvariabletoa+bsetexampletoa+b
now if i run the code as follows:
setvariableto2+4
it 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
setexampletoa+b
with
setexampleto2+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
Scratcher
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

definemoveamountmoveamountstepsmove5steps

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)

Powered by DjangoBB