Discuss Scratch

Scratch137
Scratcher
1000+ posts

Scratchblocks BBCode Help

There is a much more in-depth guide on the Wiki that covers many things not mentioned here! I highly recommend using the Wiki guide instead of this one.

For a complete list of block categories, check the Advanced Syntax section of the Block Plugin (2.0) page.


Scratch137's Forum Tutorials
Today's Category: BBCode
Today's Topic: Advanced Scratchblocks

Hello there! You've probably come for help with Scratchblocks on the forums. Well, I'm here to tell you that you came to the right place.
I'm Scratch137 and today, I'll be teaching you how to expand your knowledge on BBCode Scratchblocks.

Table of Contents
  • Custom Blocks
  • Definition Blocks
  • Make Your Own Blocks
  • Things to Try

Custom Blocks

To make custom blocks (from the More Blocks tab), type in the following code:

[scratchblocks]
custom block name :: custom
[/scratchblocks]

This should result in a block that looks like this:

custom block name :: custom

If you want to add inputs (numbers, strings, and booleans), you can add this code to the custom block:

(number) [string] <boolean>

Altogether, this should give you some code that looks like this:

[scratchblocks]
custom block name (number) [string] <boolean> :: custom
[/scratchblocks]

And a block that looks like this:

custom block name (number) [string] <boolean> :: custom

See how the number and boolean got placed in as blocks?
The number got placed in as a variable, and the boolean got placed in as an invalid block.
To fix this, unfortunately, they must be empty, like this:

custom block name () [] <> :: custom

See the difference? This is how BBCode handles the Scratchblocks command.
Using this information, we can make a (somewhat) complicated script using BBCode.

Now, let's move on to telling these blocks what to do. (They won't actually function, though, so don't get your hopes up.)

Definition Blocks

To make a definition block, type the following command:

[scratchblocks]
define custom block name
[/scratchblocks]

This will create a block that looks like this:

define custom block name

You can also add the inputs as shown before:

define custom block name (number) [string] <boolean>

They will all show as blocks. Note that numbers and strings will appear the same. This is the same with the real Scratch custom blocks.
But what if you want to put these in the script? It's actually quite simple. These inputs use the custom-arg extension instead of the custom extension.

[scratchblocks]
define custom block name (number) [string] <boolean>
if <boolean :: custom-arg> then
say (string :: custom-arg)
set [variable v] to (number :: custom-arg)
[/scratchblocks]

Note that when doing this with the string, it must be set as a number input.

define custom block name (number) [string] <boolean>
if <boolean :: custom-arg> then
say (string :: custom-arg)
set [variable v] to (number :: custom-arg)

Make Your Own Blocks

Want to make your own blocks? It's very simple. Just type what you want your block to have, then choose which category for the blocks to be from. Remember, all inputs but the string must be empty unless you want them to be input blocks (which you can also select the category for).

[scratchblocks]
read tutorial until <tutorial finished? :: sensing> :: control
[/scratchblocks]

read tutorial until <tutorial finished? :: sensing> :: control

For hat blocks, simply add the word hat before the category name:

[scratchblocks]
when tutorial opened :: hat events
read tutorial until <tutorial finished? :: sensing> :: control
[/scratchblocks]

when tutorial opened :: hat events
read tutorial until <tutorial finished? :: sensing> :: control

This even works with categories that don't have hat blocks, and you can add inputs!

when tutorial opened <continue script :: control> :: hat operators
read tutorial until <tutorial finished? :: sensing> :: control

Things to Try

Congratulations! You have successfully completed this tutorial! Here are some things to try out for yourself:

  • Hat Forever Blocks
    [scratchblocks]
    forever :: hat control
    end
    [/scratchblocks]

    forever :: hat control
    end

  • Deliberate use of Undefined Blocks
    Sometimes, it might be necessary to use undefined blocks. To do this, simply make a custom block without assigning it to a category.
    undefined

  • MORE (POSSIBLY) COMING SOON

Scratch on!
~Scratch137

Last edited by Scratch137 (Nov. 20, 2021 22:46:21)

zfn
Scratcher
68 posts

Scratchblocks BBCode Help

Super helpful!

Is there a way to make end blocks like
stop [ v]
where the is no connector at the bottom?

Last edited by zfn (Feb. 19, 2021 02:16:01)

gosoccerboy5
Scratcher
1000+ posts

Scratchblocks BBCode Help

zfn wrote:

Super helpful!

Is there a way to make end blocks like
stop [ v]
where the is no connector at the bottom?
:: cap

no cap!

Last edited by gosoccerboy5 (Feb. 20, 2021 22:05:06)


Scratch137
Scratcher
1000+ posts

Scratchblocks BBCode Help

Wow, I'd forgotten about this.
There is actually a much more in-depth guide on the Scratch Wiki. Of course, I didn't know about that page when I wrote this post.
mybearworld
Scratcher
1000+ posts

Scratchblocks BBCode Help

forever :: hat control
end
That doesn't work…
forever :: hat
{
} :: control loop
forever :: hat
{
} :: control loop

Last edited by mybearworld (Feb. 21, 2021 14:48:15)


Signatures are the only place where assets links still work.
s216654
Scratcher
65 posts

Scratchblocks BBCode Help

Try

forever :: hat {
}

-s216654-

Please Help Me With Implementing 3D Scratch

Einstein wrote:

Imagination is More Important than Knowledge
mybearworld
Scratcher
1000+ posts

Scratchblocks BBCode Help

s216654 wrote:

Try

forever :: hat {
}
Nope

Signatures are the only place where assets links still work.

Powered by DjangoBB