Build Your Own Blocks in Scratch
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
October 27th, 2008 at 8:54 am
Hi,
Great idea!
This goes to the whole of Chirp btw.
One possible issue with custom blocks I can think of:
What if a composite block contains an infinite loop, but is set to execute in one step?
October 27th, 2008 at 9:01 am
Ah, good point! a forever block inside a custom block definition will always yield after each loop in the current prototype in order to prevent just that. There are other blocks, btw, which will also ignore the atomicity setting: All times blocks, e.g. wait, play note, glide etc.
October 29th, 2008 at 2:06 am
the most awesome thing i think i have ever seen!
November 1st, 2008 at 3:37 pm
Hello,
Have you made any progress with that prototype you made earlier this year? I also have a bug, when I try to compile my *.sb 1.3 files, it will compile them, but when I launch it, that Lists IDE program comes up and says: Cannot read Header, please help!
November 1st, 2008 at 3:39 pm
Oppz, sorry, I mean: Can Not Read: Bad Header. Again, sorry about that.
November 1st, 2008 at 6:42 pm
Oh, I’m very sorry, I was just reading the forum for Chirp and I read what you said. I found the forums after I emailed this, I guess I probably should have down some more looking! I hope they post the source code soon. P.S. do you know a place to download Scratch 1.2?
November 2nd, 2008 at 3:44 am
where do you go to find out these things? where do you go to make these things?
do you know where to find a source code for scratch 1.3?
November 2nd, 2008 at 3:54 am
henley, I work on Scratch, but this is my personal project.
November 3rd, 2008 at 4:46 pm
this looks really cool but i dont understand at all how to use it…and i hate reading long instructions
November 6th, 2008 at 5:20 pm
When I press the “compile” button, where does the .exe file go? I saved it under “projects” but I can only find the .sb file there. Any ideas?
Also, in the compiled file, when I run the .exe, does the .exe file cause it to go directly into presentation mode or does the .sb file? Because if it is the .sb file, then it would work on Macs, too, as I understand it.
November 6th, 2008 at 10:25 pm
Hi coolstuff,
the compiled .exe file always goes into the documents folder. If the compilation succeeds, the documents folder should actually open automatically and display the result.
It’s the .exe file in combination with a modified .image which causes the presentation mode behaviour. You’re right, of course, that it would be possible (and even rather easy) to do the same for Macs. But I’m afraid I can’t do it, because I don’t own one
November 7th, 2008 at 7:00 am
Hi Jens,
It doesn’t open the “My Documents” folder, nor does it appear to reside in the My Documents folder, as I did a search of the HD and no file appeared by the name I had saved it as, which was “blah.sb”, so I searched for “blah.exe” and nothing appeared. Any ideas? Thanks.
November 7th, 2008 at 1:54 pm
Also, to run the “compiled” project on a mac, would I only need to open the modified .image file with the original .app Mac application of Scratch? Or are the other contents not actually visible in a folder, and if so, how would I get to them? I’m really interested in how this could work on a Mac…
November 8th, 2008 at 5:30 am
Hi coolstuff, you might have blank somewhere spaces in your filepath, that’s why the current compiler prototype might not work. I’ll try to fix this sometime soon. Let me also try to figure out something for a Mac…
November 14th, 2008 at 12:13 pm
Do these work in sratch projects? can you give a link to a project?
November 14th, 2008 at 4:36 pm
Yes jens, the umm, compiled stuff doesnt go… andywhere….. does it go to the “My documents” Folder? Where? I m Stumped
November 15th, 2008 at 1:14 am
@Zawicki1: BYOB is a prototype to try out this idea of letting users build their own blocks in Scratch. It uses a file format which is incompatible to regular Scratch, so you cannot post projects made with BYOB to the Scratch website. But you can share them as .exe files.
@cds56: The compiler still has some issues with pathnames containing blanks or spaces, so that might be the problem you’re observing. Thanks for informing me about this! I’ll look into this and try a fix sometime.
November 16th, 2008 at 11:34 am
thats an odd problem, im renaming My Documents, to MyDocuments, would that work?
November 17th, 2008 at 2:27 pm
how did you get the 1.3 sorce code?
November 18th, 2008 at 12:59 am
@cds56: I wouldn’t rename any system folders just yet. The output folder is usually not the problem, the input one is, though (the one where the source project is located). Hang on, I’m about to fix this for the next release!
@john: I’m working on Scratch
November 20th, 2008 at 12:55 pm
I jest got this and it’s very cool!
November 23rd, 2008 at 6:23 am
i have a problem…..
i downloaded it but when i choose reporter or Boolean block it does not let me insert the answer into the report cavity at the bottom.
November 23rd, 2008 at 8:17 am
Hi Tsomething,
inserting something into the block editor’s “report” field sometimes takes a lot of fiddling around. I really ought to make that part better! Sometimes it works best if you drop the answer slightly to the left of the report-field onto the label.
November 23rd, 2008 at 12:57 pm
yes i figured that out now
thanks!
November 24th, 2008 at 4:44 pm
Yes. And I have figured out that you cannot rename the folder anyways.
December 4th, 2008 at 11:33 pm
The % block thing won’t work for my mum’s Vista.
Is it a bug?
December 4th, 2008 at 11:34 pm
Oh and it says Subscript is out of bounds
December 10th, 2008 at 8:34 pm
neato!!!
December 12th, 2008 at 6:47 pm
Sounds great! but i can’t find where to download it!
December 12th, 2008 at 6:49 pm
BTW: henley, go to jens source project , it tells u how to get at the 1.3 source. NOT 1.3.1, though.
December 19th, 2008 at 10:19 pm
cool!
December 28th, 2008 at 2:39 pm
Hi, jens.
I’m working on my own version of scratch (kinda like chirp), and am ready for the first release. But here’s the thing: when I call the “fillScreenOn” function, it does everything it’s supposed to, sets “scratchFrameMorph” to fill the screen, enters novice mode, etc. But here lies the problem. I can’t save the image file in this state, because I can’t access the world menu. If it isn’t too much trouble, how did you do this to save the final version of chirp?
December 28th, 2008 at 2:44 pm
Auron: if it says ’subscript is out of bounds’ it means that you tried to put too much into what is supposed to be a single line of text. To preserve memory, scratch wraps long strings onto other hidden lines; the subscript. However, there is a limit (bound) to how long the subscript can be. hope this helps!
December 29th, 2008 at 12:47 am
Hi billyedward,
to save a “deployable” version of your own Scratch derivative, just select “save image in user mode” from the Extras-menu in the Source Code release, i.e. without switching to user mode first. I’m very curious about your work, which features did you add?
December 31st, 2008 at 7:14 am
Hi Jens
First , I have to give my thanks for your release Scratch2exe.
It give us lots of help.
I am from Taiwan. My English is so bad, I try to make myself clear,
If it is possible that you can develop another function, that we can let our projects to SWF?
Sorry to ask for this.
it will be great if you can give me a mail.
bigfrog@bigfrog.com.tw
December 31st, 2008 at 8:14 am
Can I use this in 1.3.1 source?
January 2nd, 2009 at 3:40 am
Hi BigFrog,
converting Scratch projects to flash is currently not on my short-term agenda, sorry.
Hi abeair,
The BYOB image is currently pretty much “locked down”, preventing you from accessing the source code. I’m planning to release the BYOB source code after the next update or so (I’m in the process of adding some more features, like inter-sprite messages with parameters)
January 4th, 2009 at 3:10 pm
Hi, Jens, thanks!
The reason that I didn’t notice that is that I wasn’t using the published code. However, I copied the code that that option runs, into a workspace, then ‘did it now’. It worked great, Thanks!
My new features are pretty elementary:
1. I added ‘factorial’ to the function block
2. I brought back the old image effects.
3. I added a ‘enter/exit compatible mode’ option to the shift+extras menu.
4. When not in compatible mode, it saves a *.sc, instead of *.sb
5. when not in compatible mode, two new reporter blocks appear:
-hidden?
-pen down?
6. I changed all the spellings of ‘color’ to the proper english ‘colour’. (for compatibility, it can still read ‘color’ in the image effects)
7. When you press shift while entering presentation mode, it doesn’t enter fullscreen.
8. I also added to shift+extras a enter/exit full screen option. This is usually only done for presentation mode, but now you get more space to edit!
9. pressing shift while changing pallette categories, or opening a project, makes the blocks darker. this increases contrast, aiding the visually impaired.
10. there is a ‘enter/exit’ blind mode shift+extras option. this makes the menus bigger.
11. I’ve brought back some of the working/useful obsolete blocks.
12. I’m usre there’s more, which I’ve forgotten
If you want to use any of my ideas for chirp- go ahead.
January 6th, 2009 at 3:10 pm
How do I install
January 6th, 2009 at 3:12 pm
Got it never mind
January 10th, 2009 at 6:53 pm
Hi, jens. Just wondering…
the
^ self beep
January 10th, 2009 at 6:56 pm
Hi Jens-
Another quick question:
you know the
^ self beep
command in squeak?
I’ve tried to make a block in sound that does this, but when I run it, squeak entirely freezes.
Do you know What’s going on?
sorry about this,
Thanks.