So, you want to define your own procedures and functions in Scratch? Build your own blocks (BYOB )?
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
Offline
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
Wow. Once again an amazing accomplishment. I'll have to take a look at it asap...
Offline
[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!
Offline
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 . Thank you!!!
Last edited by fullmoon (2008-10-21 17:12:08)
Offline
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!
Offline
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.
Offline
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.
Offline
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"
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 . 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).
Offline
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?
Offline
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?
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...
Offline
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!
Offline
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)
Offline
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!
Offline
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
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)
Offline
and when you quit it says "scratch"
Offline
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
Build your own blocks
Offline
the sprite you start out with is at 1,1 not 0,0
Offline
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?
Offline
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)
Offline