Discuss Scratch

theonlygusti
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

Guys, too many people seem to be trying out their scratchblocks in this topic. While I appreciate you may be excited, please use the official testing topic to test your newfound skills: https://scratch.mit.edu/discuss/topic/219704/ DON'T SPAM THIS TOPIC

In this topic, I hope to teach you how to become a [scratchblocks] wizard!

Lots of the cool tricks in scratchblocks aren't easily found anywhere, but they can be really helpful amongst the forums, especially in suggestions, where you sometimes have to make up your own blocks. Scroll right to the bottom to see how to do this.

Now, this tutorial will probably have you itching to try out your new scratchblocks skills, and I don't mind you posting a little bit in this topic to follow along, but once you're done, use the proper testing topic to post all of your scratchblocks wizardry - https://scratch.mit.edu/discuss/topic/219704/

So, firstly:

What is Scratchblocks?

Scratchblocks is a BBCode plugin that allows you to display scripts within the forums. It was created by the scratch user blob8108 and implemented by nXIII.

It is useful for suggestions and within the help with scripts forums, because you can show exactly what you mean:

when gf clicked
say [Hello there!] for (2) secs

But you have to remember not to spam with it! Only use it when necessary, never write an entire post in nothing but scratchblocks.

How can I use it?

To use the scratchblocks plugin, just put [scratchblocks] and [/scratchblocks] around all of your text.

[scratchblocks]
// all of your scratchblocks scripts go here, in between the tags.
[/scratchblocks]

Simple Scratchblocks

This section will teach you the basics of scratchblocks.

In most blocks, you can just type out all the text that displays on the block, and it will work:

[scratchblocks] hide [/scratchblocks]
will create
 hide 

But this will only work for blocks that have no inputs. If you want to create a block with inputs, you need to put brackets around the input.

Use square brackets, , for text, and round brackets, (), for numbers:

[scratchblocks]
say [Hello, World!] for (2) secs
[/scratchblocks]

say [Hello, World!] for (2) secs

Notice how I used the different types of bracket?

Now, for a drop down list, you still use brackets, but you have to put a v just before the closing bracket.

Note: you still use round brackets for number drop downs, and square brackets for text drop downs:

[scratchblocks]
replace item (42 v) of [Numbers v] with [The answer!]
[/scratchblocks]

replace item (42 v) of [Numbers v] with [The answer!]

With drop downs, it's important which type of bracket you use to make it appear correctly.

There's one more type of input, the color-picker input. This is created by specifying within square brackets [] the hexadecimal color code of the color you want to appear in the input,

[scratchblocks]
set pen color to [#ff0000]
[/scratchblocks]

set pen color to [#ff0000]

So far we've looked at stack blocks, and inputs. You can create other blocks as well, but first I'll show you how to put multiple blocks together:

[scratchblocks]
say [Hello!]
hide
add [item] to [list v]
show
point in direction (0 v)
[/scratchblocks]

say [Hello!]
hide
add [item] to [list v]
show
point in direction (0 v)

That's right! It's as easy as putting the next block on the next line!

Now that you've learned some of the basic basics, we can look at c-blocks, symbols and other shapes:

More complex, yet still basic, block types

For these blocks, you still type exactly what's on the block, but they require some extra knowledge to work properly:

For the green flag block, you can type any of the following:
  • when green flag clicked
  • when flag clicked
  • when gf clicked

I will use the last one though, because it's the shortest one to type, but you can use whichever version you like the most.

[scratchblocks] when gf clicked [/scratchblocks]
when gf clicked

What about some other symbols?

For the turn block, you can type any of the following:
  • turn cw (15) degrees
  • turn right (15) degrees
  • turn ccw (15) degrees
  • turn left (15) degrees

As you can see, we are replacing the symbol with words.

cw stands for clockwise, and draws an arrow turning clockwise, and ccw means counter-clock wise, and draws an arrow turning counter clock-wise.

Right and cw draw the same arrow, as do left and ccw. It's personal preference which one you use, but I use cw and ccw because they are shorter and unambiguous.
[scratchblocks]
turn cw (15) degrees // could be turn right (15) degrees
turn ccw (15) degrees // could be turn left (15) degrees
[/scratchblocks]

turn cw (15) degrees // could be turn right (15) degrees
turn ccw (15) degrees // could be turn left (15) degrees
But what's this?

In this example you saw how to use a comment, by putting two forward-slashes, //, in front of your comment.

You can make attached comments, and also free-standing comments:
[scratchblocks]
hide // attached comment
// free-standing comment
[/scratchblocks]
hide // attached comment
// free-standing comment

Now, onto c-blocks!

A c-block looks like this:
forever
end

And can be created like this:
[scratchblocks]
forever
end
[/scratchblocks]
notice how you have to write end at the end of your c-block?

NOTE: I indent the blocks inside my c-loops for readability. Normally I don't do this, and it is not necessary.

This is how to tell it where to stop, so you can do:
[scratchblocks]
repeat (2)
hide
end
show
[/scratchblocks]
repeat (2)
hide
end
show
note how the c-block only wraps around the scripts before you write end, and then stops as soon as you write end? This is very useful.

You create if-else blocks in a similar fashion,

[scratchblocks]
if <((2) + (2)) = [5]> then
say [Freedom is slavery.]
else
say [Peace is war.]
end
[/scratchblocks]

if <((2) + (2)) = [5]> then
say [Freedom is slavery.]
else
say [Peace is war.]
end

But wait! What's this? A new block!

Predicates are the diamond-shaped blocks within scratch, sometimes called booleans (but they shouldn't be). In scratchblocks, they are created with the < and > symbols:

[scratchblocks]
wait until <mouse down?>
[/scratchblocks]

wait until <mouse down?>

And reporters, the round blocks, are made using normal brackets, ():

[scratchblocks]
wait ([sin v] of (90)) secs
[/scratchblocks]

wait ([sin v] of (90)) secs

To use variables in scratchblocks, you just write the name of the variable within round brackets:

[scratchblocks]
change y by (gravity)
[/scratchblocks]

change y by (gravity)

And when it comes to custom blocks, scratchblocks becomes really clever; it remembers which names were arguments and which were not!

[scratchblocks]
define square (width)
pen down
repeat (4)
move (width) steps
turn cw (90) degrees
end
pen up
[/scratchblocks]

define square (width)
pen down
repeat (4)
move (width) steps
turn cw (90) degrees
end
pen up

Now, finally, the complex stuff!

In scratchblocks you can force blocks to appear however you want them to, e.g.
using ((seven :: custom reporter) :: custom-arg ring) {
} :: sensing

First, I will teach you how to color your block, in (almost) any way you want.

To do this, you have to learn all the categories of blocks:

  1. events
  2. control
  3. sound
  4. sensing
  5. pen
  6. looks
  7. operators
  8. list
  9. variables
  10. custom
  11. motion
So, those were all the “normal” block categories, but there are also some extra ones you can use to color your block:
  • grey
  • extension
  • custom-arg
  • obsolete
These categories are used to say which category your blocks should be colored as, for example:

[scratchblocks]
set [var v] to (1) // normal
set [var v] to (1) :: motion // as a motion block
[/scratchblocks]

set [var v] to (1) // normal
set [var v] to (1) :: motion // as a motion block
As you can see, you write down your block as normal, but then put two colons, ::, and the name of the category.

Notice that you can still put comments after you apply your styles.

Custom Colors!

A little-known fact is that you can actually apply customised colors to your block, using hexadecimal color codes!

[scratchblocks]
( :: operators #ffffff) yin :: #000000
yang (yang :: operators #000000) :: #ffffff
[/scratchblocks]

( :: operators #ffffff) yin :: #000000
yang (yang :: operators #000000) :: #ffffff

Custom Shapes

You can also shape blocks however you want, here are the shapes you will need to know:

  1. stack
  2. hat
  3. ring
  4. reporter
  5. boolean
  6. cap

You apply shapes in exactly the same way, e.g.
[scratchblocks]show :: hat[/scratchblocks]
show :: hat 

And you can use shapes and colors together, by putting spaces between them:
[scratchblocks]
when <> :: hat events
[/scratchblocks]
when <> :: hat events

There's another shape of block we can define ourselves, the c-block:
[scratchblocks]
hide {
} :: operators
[/scratchblocks]
hide {
} :: operators
Notice that we use curly-braces to separate the contents of the cblock from the block itself.

[scratchblocks]
run script {
} without screen refresh :: control
[/scratchblocks]

run script {
} without screen refresh :: control

Some of the shapes are really weird and have an interesting origin, for example ring, which was meant to be used to mimic Snap! and BYOB blocks

[scratchblocks]
map ((() * (2)) :: grey ring) over [list v] :: list
[/scratchblocks]

map ((() * (2)) :: grey ring) over [list v] :: list

There is also one more type of input, which you must between round brackets, (), a block! You can make blocks appear inside other blocks, like this:
[scratchblocks]
this is (a block :: sensing stack) :: custom-arg stack
[/scratchblocks]

this is (a block :: sensing stack) :: custom-arg stack

Notice two things: the block is styled inside the brackets, and the use of :: stack.

You can style all types of block within their brackets:

[scratchblocks]
if <true :: operators boolean> then
end
[/scratchblocks]

if <true :: operators boolean> then
end

and now, you're on your way to becoming a true, scratchblocks ninja!

[scratchblocks]
when gf clicked :: operators hat
wait until (this block :: looks stack) turns purple {
say hi! :: sound stack
} and then {
use the colors {
to make life :: motion stack
} :: custom-arg cstart
} finally :: extension
stop :: grey cap
[/scratchblocks]
when gf clicked :: operators hat
wait until (this block :: looks stack) turns purple {
say hi! :: sound stack
} and then {
use the colors {
to make life :: motion stack
} :: custom-arg cstart
} finally :: extension
stop :: grey cap

Remember, use the proper testing topic to try out your new-found skills: https://scratch.mit.edu/discuss/topic/219704/

Last edited by theonlygusti (Jan. 9, 2017 22:43:03)


theonlygusti
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

Now, I know I'm probably missing some block categories, or just something, so leave your suggestions for improvements

theonlygusti
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

Remember, only use this topic to follow along with the tutorial, ask for questions and suggest things I missed.

To test out your newly acquired skills, use this stickied topic by jvvg http://scratch.mit.edu/discuss/topic/14778/

Techno-CAT
Scratcher
500+ posts

ITopic: Everything you never knew about [scratchblocks]!

theonlygusti
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

Techno-CAT wrote:

Duplicate
It's not a duplicate.

The person who made that didn't show any of the extra stuff you can do with scratchblocks, they only showed the pure basics.

Last edited by theonlygusti (Oct. 5, 2014 13:14:35)


MrSherlockHolmes
Scratcher
500+ posts

ITopic: Everything you never knew about [scratchblocks]!

Thanks.

Centred signature.
RPFluffy
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

Techno-CAT wrote:

Duplicate

Not true as you can't duplicate guides because they can be different AND I prefer this one…

But anyways GREAT introduction to BBcode for beginners!

Last edited by RPFluffy (Oct. 5, 2014 16:42:16)


Nothing Is EVER 100%, that is just an assumption.















Some important links: Here and here or need help click Here. Eats followers, Loves helping people.
My “..” and “…” are not spelling mistakes, it means that they are ways of telling someone that I can continue more about it and that the sentence isn't ended the best way. I like putting new indents and lines so I can split up what I am talking about.




































Some important links: Here and here or need help click Here. Eats followers, Loves helping people. Check this MMO out! Kiwi = Support WHAT THAT'S IMPOSSIBLE: Through the drop down ;)
if <> :: control cstart

else :: control
end
theonlygusti
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

RPFluffy wrote:

Techno-CAT wrote:

Duplicate

Not true as you can't duplicate guides because they can be different AND I prefer this one…

But anyways GREAT introduction to BBcode for beginners!
Thanks! I tried my best, is there anything else I should add though?

RPFluffy
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

theonlygusti wrote:

RPFluffy wrote:

Techno-CAT wrote:

Duplicate

Not true as you can't duplicate guides because they can be different AND I prefer this one…

But anyways GREAT introduction to BBcode for beginners!
Thanks! I tried my best, is there anything else I should add though?

Actually (I almost never say this, which means that this is REALLY GOOD) there really is nothing you can add except maybe a little more explanation and grammar check.

Nothing Is EVER 100%, that is just an assumption.















Some important links: Here and here or need help click Here. Eats followers, Loves helping people.
My “..” and “…” are not spelling mistakes, it means that they are ways of telling someone that I can continue more about it and that the sentence isn't ended the best way. I like putting new indents and lines so I can split up what I am talking about.




































Some important links: Here and here or need help click Here. Eats followers, Loves helping people. Check this MMO out! Kiwi = Support WHAT THAT'S IMPOSSIBLE: Through the drop down ;)
if <> :: control cstart

else :: control
end
theonlygusti
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

RPFluffy wrote:

Actually (I almost never say this, which means that this is REALLY GOOD) there really is nothing you can add except maybe a little more explanation and grammar check.
Thank you!

Last edited by theonlygusti (Oct. 5, 2014 16:50:43)


epicsandwich123
Scratcher
100+ posts

ITopic: Everything you never knew about [scratchblocks]!

epic! i think it should be stickied!

ever wanted some awesome sening blocks? http://scratch.mit.edu/discuss/topic/45738/
how about copying and pasting? http://scratch.mit.edu/discuss/topic/41980/

#sorry, but games coming soon. check my old account, awesomegames123!
RPFluffy
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

epicsandwich123 wrote:

epic! i think it should be stickied!
Agreed!
(Reporting to be stickied…)

Last edited by RPFluffy (Oct. 5, 2014 17:19:38)


Nothing Is EVER 100%, that is just an assumption.















Some important links: Here and here or need help click Here. Eats followers, Loves helping people.
My “..” and “…” are not spelling mistakes, it means that they are ways of telling someone that I can continue more about it and that the sentence isn't ended the best way. I like putting new indents and lines so I can split up what I am talking about.




































Some important links: Here and here or need help click Here. Eats followers, Loves helping people. Check this MMO out! Kiwi = Support WHAT THAT'S IMPOSSIBLE: Through the drop down ;)
if <> :: control cstart

else :: control
end
Tropic
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

First you wrote 'scratchblocks ninja“, then ”scratchblocks wizard“ and then ”scratchblocks ninja" again xD
Should it be ninja or wizard?

(btw, I think someone said that I was a scratchblocks wizard once, was that why you wrote scratchblocks wizard instead of ninja?)



My browser / operating system: Windows NT 10.0, Firefox 40.0.2, Flash 20.0 (release 0)
Last eaten by Evil Kumquat (Today 19:30:11)
when I receive [flash_player_version] :: motion
say [Windows 7, Flash 15.0 (release 0)] :: sensing
stop script :: custom
Tropical Productions
theonlygusti
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

Tropic wrote:

First you wrote 'scratchblocks ninja“, then ”scratchblocks wizard“ and then ”scratchblocks ninja" again xD
Should it be ninja or wizard?

(btw, I think someone said that I was a scratchblocks wizard once, was that why you wrote scratchblocks wizard instead of ninja?)
Yes, I wrote wizard just for you!

Actually, I put both wizard and ninja because using these skills, you will became a scratchblocks ninja-wizard!

Tropic
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

theonlygusti wrote:

Tropic wrote:

First you wrote 'scratchblocks ninja“, then ”scratchblocks wizard“ and then ”scratchblocks ninja" again xD
Should it be ninja or wizard?

(btw, I think someone said that I was a scratchblocks wizard once, was that why you wrote scratchblocks wizard instead of ninja?)
Yes, I wrote wizard just for you!

Actually, I put both wizard and ninja because using these skills, you will became a scratchblocks ninja-wizard!
And you used master too in another post



My browser / operating system: Windows NT 10.0, Firefox 40.0.2, Flash 20.0 (release 0)
Last eaten by Evil Kumquat (Today 19:30:11)
when I receive [flash_player_version] :: motion
say [Windows 7, Flash 15.0 (release 0)] :: sensing
stop script :: custom
Tropical Productions
gcenac
Scratcher
100+ posts

ITopic: Everything you never knew about [scratchblocks]!

I like it, and I think it should be stickied. Although for it to be stickied, maybe make the title better? Easier to read, use capitals and such… Just a tiny thing…


theonlygusti
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

gcenac wrote:

I like it, and I think it should be stickied. Although for it to be stickied, maybe make the title better? Easier to read, use capitals and such… Just a tiny thing…
OK thanks for your feedback, I will work on the title.

MegaApuTurkUltra
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

cool tutorial::custom hat
>>>::cstart list
didn't know about these: {sup (derp::stack operators)::variables ring}:: sensing // lol glitch
or this::celse motion
but I knew about everything else!::celse
so good job::cend cap

Last edited by MegaApuTurkUltra (Oct. 6, 2014 12:15:28)


sadly, my signature was eaten by some ST
theonlygusti
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

MegaApuTurkUltra wrote:

cool tutorial::custom hat
>>>::cstart list
didn't know about these: {sup (derp::stack operators)::variables ring}:: sensing // lol glitch
or this::celse motion
but I knew about everything else!::celse
so good job::cend cap
Thanks!

ChocolatePi
Scratcher
1000+ posts

ITopic: Everything you never knew about [scratchblocks]!

when green flag clicked :: motion
say { ninja! } :: sensing
think {say [sorry for blockspam ] :: variables }
set { but this is so :: motion } to (fun)

Powered by DjangoBB

Standard | Mobile