This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-10-21 09:14:51

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

ITopic: Build Your Own Blocks (BYOB)

So, you want to define your own procedures and functions in Scratch? Build your own blocks (BYOB  smile  )?

You might as well try this new experimental prototype I have been developing over the last weeks. You can download and read through an overview (pdf), or download the whole application (including the overview) and start playing with it right away.

This prototype lets you build your own custom blocks in Scratch using the standard Scratch blocks, as well as other blocks you defined elsewhere. You can create your own command blocks (procedures) and reporter blocks (functions), both regular ("round") and boolean ("diamond"). You can specify for each block to be atomic (run at the speed of a single block) or interleafed. Your custom blocks are defined for each sprite and can be shared among projects together with the sprite they were created for. Oh, and you can even use a block within itself (recursion).

This prototype is very, very, experimental, so be prepared to encounter lots of bugs. I'd be very interested in feedback about your experiences and insights.

Enjoy!
-Jens


Jens Mönig

Offline

 

#2 2008-10-21 12:02:09

ericr
Scratch Team
Registered: 2007-03-21
Posts: 23

Re: ITopic: Build Your Own Blocks (BYOB)

awesome.  I made the classic recursive tree, but it redraws in a loop so you change parameters interactively.  Fun.  Here's the project (which has to be loaded into Jens' BYOB app for it to work):

http://web.mit.edu/~eric_r/Public/scratch/tree.sb

Offline

 

#3 2008-10-21 13:50:19

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: ITopic: Build Your Own Blocks (BYOB)

Wow. Once again an amazing accomplishment. I'll have to take a look at it asap...

Offline

 

#4 2008-10-21 14:11:10

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

[bugfix]

I just discovered and fixed an annoying bug that happens when you try to re-edit an existing block spec. So, if you have already downloaded the prototype, please do so once again and make sure the version number in the Extras-About dialog says BYOB 1.0.2. This does not affect any projects created with the original version.

Thanks!


Jens Mönig

Offline

 

#5 2008-10-21 17:01:25

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

Doesn't "BYOB" stand for "Bring Your Own Beer"? Other than that, I am blown away! I'm supposed to be writing a Scratch presentation for school, but instead I think I'll spend the rest of the day playing with this  wink . Thank you!!!

Last edited by fullmoon (2008-10-21 17:12:08)


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#6 2008-10-21 17:28:37

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

Jens, this is simply amazing!  Astounding!  Incredible!  The first routine I made was "Previous Costume" - it felt so good to be able to hide that ugly equation neatly away in a routine where it belongs!  From my first baby steps, I will now stride forth confidently.  Thank you!


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#7 2008-10-21 17:36:54

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

One "bug" I found: adding a colon ":" in a block spec will place the part of the block spec after the colon in a new number reporter inside the block header in edit mode. Try to drag the unwanted reporter out of the block header; it can't be done. I am using version 1.0.2.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#8 2008-10-21 17:39:34

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

The block spec dialog will not let you add other reporter slots besides number (%n) to a block. Try %s, %b, etc. It won't distinguish between these names, either, so if you create a block called %n and then one called %s, an alert will pop up saying a block with such a spec already exists.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#9 2008-10-22 02:28:18

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

Thanks for your feedback about BYOB!

fullmoon wrote:

Doesn't "BYOB" stand for ... ?

I guess it stands for a lot of things, not just for transporting beverages. I've also seen it printed on reusable bags as in "bring your own bag"  smile

limitations in editing block specs

defining custom blocks by letting users enter a parseable string requiring special characters to mark parameter placeholders is plain ugly, I agree. But it just happens to be easiest and quickest to implement  big_smile  . Ideally there would be a graphical "header editor" letting you assemble block specs by dragging and dropping bits and pieces out of a special "header-toolbox". This might be another interesting project in the future...

In the meantime there are some limitations in editing block specs. One such limitation is that when checking for an already existing block spec the prototype does not take the parameter names into account. This makes sense, because you don't see the (block-internal) paramter names in blocks palette. But it also prevents you from renaming only the parameter names in a block spec. One way to cope with this is to do it in two steps: First change something else in the block spec, accept, then change it back and rename the parameter (this is how I do it).


Jens Mönig

Offline

 

#10 2008-10-22 10:56:45

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

Wow Jens...

paddle2see wrote:

simply amazing!  Astounding!  Incredible!

I especially like the way you can turn Scratch into a high speed programming language...

I tried drawing a shape (a fade-from-black-to-white rectangle) dynamically.
Adding it to a forever loop and inserting "go to mouse pointer" results in a moving  faded rectangle. Wow...

I hope it could be implemented in the next version of Scratch!

Joren

PS: It seems to be based on Scratch 1.3 source, do you have the source code?  big_smile


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#11 2008-10-22 16:50:53

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

JSO wrote:

I hope it could be implemented in the next version of Scratch!

Joren

PS: It seems to be based on Scratch 1.3 source, do you have the source code?  big_smile

Based on what happens with lists, it seems Jens may have become part of the Scratch development cycle, so I hope to see this in 1.4...


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#12 2008-10-22 17:37:26

Elad
Scratcher
Registered: 2007-12-01
Posts: 2

Re: ITopic: Build Your Own Blocks (BYOB)

My name is Asaf (I am Elads Father)

Jens,
Can you recommand of Squeak tutorial?

Thank you

Offline

 

#13 2008-10-23 02:18:13

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

Hi Asaf,
to learn Squeak Smalltalk I'd recommend looking at the materials in this forum post.

ericr wrote:

I made the classic recursive tree

http://web.mit.edu/~eric_r/Public/scratch/tree.sb

Thanks, Eric! This is beautiful, I didn't even know about that logo tree until I looked at your project. I love how the branches change colors and size. Actually, when I played with this I turned the atomic flag off and took it out of the forever loop, because I loved to follow how it redraws. Nice!


Jens Mönig

Offline

 

#14 2008-10-23 19:51:27

Paulwe
Scratcher
Registered: 2008-03-06
Posts: 16

Re: ITopic: Build Your Own Blocks (BYOB)

I had a brilliant idea!  What if someone made a block that would import files (like .gif, .avi, .wav, ect) and folders.  If someone connected to a network, downloaded (or made) a project, then added that block, selected the network for the file, and received data from it, scratch would be multi-player!!

Last edited by Paulwe (2008-10-23 20:20:00)


♬♫ 92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature. ♫♪

Offline

 

#15 2008-10-24 05:36:33

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

I just did a quick and dirty implementation of the recursive 4 way flood fill algorithm using BYOB.  I used a 3 x 3 pixel stamp to reduce the number of operations but still have a fill with reasonable quality.  With BYOB's atomicity feature, I was getting fill times of under 10 seconds for shapes of 150 pixels long or so.  Pretty respectable for a very inefficient algorithm!


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#16 2008-10-24 06:44:35

lipflip
Scratcher
Registered: 2008-05-17
Posts: 4

Re: ITopic: Build Your Own Blocks (BYOB)

Pretty impressive work!
Can you elaborate on how you handle atomic procedures that take some time?
You wrote in your tutorial that you use ESC to break stop program execution.

I have a similar problem with a block that waits for a remote server to reply and I can't get it to work asynchronously. So every time the server is busy Scratch's UI freezes.

I'm not that good with Squeak/Smalltalk, so I haven't found a good way to deal with this yet.

Offline

 

#17 2008-10-24 12:55:33

jcubed
Scratcher
Registered: 2008-07-23
Posts: 65

Re: ITopic: Build Your Own Blocks (BYOB)

well... wow...
add it so you can have more than just numbers to work with like <(  <<>  )>

Last edited by jcubed (2008-10-24 13:05:03)


Jcubed
Proud founder of Icdzat Productions.

Offline

 

#18 2008-10-24 14:07:19

jcubed
Scratcher
Registered: 2008-07-23
Posts: 65

Re: ITopic: Build Your Own Blocks (BYOB)

and when you quit it says "scratch"


Jcubed
Proud founder of Icdzat Productions.

Offline

 

#19 2008-10-24 15:45:44

Songheadstudios
Scratcher
Registered: 2008-07-28
Posts: 8

Re: ITopic: Build Your Own Blocks (BYOB)

I am having a problem, I have Broken out of scratch 1.3 and made some changes,
now I want to get back into "user mode" but how do I?

Offline

 

#20 2008-10-24 18:56:39

keroro645
Scratcher
Registered: 2008-06-07
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

I found out that byob stands for build your own bag

Offline

 

#21 2008-10-24 23:57:23

jcubed
Scratcher
Registered: 2008-07-23
Posts: 65

Re: ITopic: Build Your Own Blocks (BYOB)

Build your own blocks


Jcubed
Proud founder of Icdzat Productions.

Offline

 

#22 2008-10-25 01:22:29

jcubed
Scratcher
Registered: 2008-07-23
Posts: 65

Re: ITopic: Build Your Own Blocks (BYOB)

the sprite you start out with is at 1,1 not 0,0


Jcubed
Proud founder of Icdzat Productions.

Offline

 

#23 2008-10-25 10:49:38

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

jcubed wrote:

add it so you can have more than just numbers to work with like
[blocks]<( less than )>[/blocks]

Interesting suggestion, jcubed! I have thought about this but didn't come to any conclusive result what you would be able to do with such a boolean parameter. Could you perhaps give an example?


Jens Mönig

Offline

 

#24 2008-10-25 11:19:47

keroro645
Scratcher
Registered: 2008-06-07
Posts: 1000+

Re: ITopic: Build Your Own Blocks (BYOB)

jcubed wrote:

Build your own blocks

I no.On the ripleys believe it or not there was a build your own bag(byob).Ithink

Offline

 

#25 2008-10-25 14:04:48

jcubed
Scratcher
Registered: 2008-07-23
Posts: 65

Re: ITopic: Build Your Own Blocks (BYOB)

Jens wrote:

jcubed wrote:

add it so you can have more than just numbers to work with like
[blocks]<( less than )>[/blocks]

Interesting suggestion, jcubed! I have thought about this but didn't come to any conclusive result what you would be able to do with such a boolean parameter. Could you perhaps give an example?

example(as a reporter):
this is the best one
(if %b return %n else %n)

example(as a boolean):
<%b and %b or %b and %b>

example(as a command):
[if %b change var %? by %n]

also,you cant type numbers into the blocks

and add list for the blocks

Last edited by jcubed (2008-10-25 14:16:19)


Jcubed
Proud founder of Icdzat Productions.

Offline

 

Board footer