This tutorial will give you a basic feel for the MIT squeak editor, and altering Scratch in general. I have tried to include numerous images and such to make it as clear as possible, but feel free to comment with any suggestions.
Let's begin with the blank gray screen of squeak. First left click on that gray, select “open…,” and select “Scratch/Streak”.
This opens a draggable-around Scratch/Streak window.
To resize hold alt and click on the window, and drag the “”pin.
OK, now do the same as above, but this time select “browser” from the “open” list.
This opens the system browser, what most of the programming will go in to:
The little green circle allows you to resize this window. Just hover over the edge to get it. The X quits the window, the “O” minimizes, and the paper opens the window options. You’ll notice the 4 navigation panes above, and the coding pane below. These let you navigate and change the hierarchy of Scratch/Streak. The “instance|?|class”
Is for the 3 main categories. “Class” generally defines that an object exists, whereas instance defines what it does. ? is for comments, which don’t work. Lets get started. Navigate as follows: 1 Scratch-Objects, 2 ScriptableScratchMorph, 3 Class, 4 Scratch, 5 Blockspecs:
See how I highlighted “(‘if %b’ #c #doIfElse)”? This is the basic syntax for defining the existence of a block. There is:
• opening bracket
• single quote
• The text to be displayed on the block, input areæ represented by %letter, such as %n is a numerical inserter, %b is Boolean. Here's the full list:
a:attribute of another sprite, such as X position or size. b:a boolean inserter c:a colour picker that shows the menu. C:a colour picker that doesn't d: the sprite direction menu/numerical inserter. D: the menu for midi drums e: The broadcast message menu f: math function menu (with sin, abs, etc.) g: menu for the different graphic effects. h: numerical sensor board selector menu H: boolean sensor board selector menu i: midi instrument menu/numerical inserter k: menu for the names of the different keys, used in the key sensor blocks. l: menu with the costume names of the given sprite. L: list name menu. m: sprite list n: numerical inserter N: note name menu/inserter s: string inserter S: sound selector menu v: variable labels menu y: menu used to delete either a number of the last value or all of a list.
• Single quote
• “#” sign.
• Letter representing the block type, - being a normal command block, b is Boolean, r a reporter, c is a bar.
• “#” sign.
• Message to be corresponded in the instance side.
• This may be followed by Another one or few stand alone numbers, # followed by a number, or value in single quotes. These define the default value of the inserters.
• Closing bracket.
The message can also define special forms, such as the above’s corresponding function tells how to do the else bar.
What we now want to do is go over to “obsoleteBlockSpecs.”
Highlight each section…
And Copy/Paste into the corresponding section of “blockSpecs”: (See that ‘numbers’ before? All following this will show under numbers.
Now right click “accept”
Et Voila! You’ve resurrected an “obsolete” block!
Repeat this process for the rest. These blocks will work in normal Scratch/Streak, they’ll just be red.
Now that we have the obsoletes’, lets try some other cheats. Go to:
1 Scratch-Objects, 2 ScratchSpriteMorph, 3 Class, 4 Scratch, 5 Blockspecs:
See in the single quotes of both where it’s says 'color'?
Change this to, say saturation:
Which, when accepted, gives this: , Which produces this:
Neat,eh? Try setting it to blur, pointillize, or water as well!
One more thing: go back to 1 Scratch-Objects, 2 ScriptableScratchMorph, 3 Class, 4 Scratch, 5 Blockspecs, and find the equals block: . See the
‘#- #-‘? This means that the two inserters will be blank. If, however, you put a string into them (replacing the dash), then they will be forced to hold it. How scratch does this is to “temporarily” make it a square string inserter. () You could also change the “%n” to a “%s” which is the “code” for a string inserter, but that would render it incompatible with normal Scratch/Streak. Using the above methods you can also make entirely new blocks:
And force stuff into other blocks:
Another thing you can do is:
Drag a block out to the gray, and Alt+click it.
Click the red menu icon, and select change colour…
Edit as you wish… And use in your Scripts!
Certain other blocks can only easily be gotten by going to the version of Scratch/Streak it came from. The 1.2beta comment block is an example:
It’ll show up red in everything after 1.1, gray in 1.2beta. It is obsolete before 1.2.
Hope this helps in your endeavor to utilise the scratch source code!
I will make a more advanced collection of information soon, for those who want to continue.
Last edited by billyedward (2011-04-24 22:56:39)
Offline
Really nice guide, I'll be using this.
Last edited by hmnwilson (2010-02-24 01:09:00)
Offline
Billyedward - Are you interested in helping me with this (http://scratch.mit.edu/forums/viewtopic.php?id=29439 ) ? You're a source code pro after all ^^
Very cool tricks you shared btw
Offline
One question: If you edit the source code and make new blocks like these, can the project with the new blocks be uploaded to the website normally?
Offline
floatingmagictree wrote:
One question: If you edit the source code and make new blocks like these, can the project with the new blocks be uploaded to the website normally?
The obsolete ones DO work in normal, unhacked scratch, but not online, as do the special image effects. Unfortunately, though, the blocks that you create from scratch (pun intended) only work in the version that you've made.
So no, none work online .
Offline
Yay! Zombie blocks!!
Offline
That's incredible!
Offline
Wow!
And it works online and downloaded even if you haven't saved it with the new settings...
Offline
Offline
Hmm, you're pretty good at source code, billyedward. Thanks for this guide, I'm going to put this to the test today.
Offline
nXIII wrote:
Hm... do all the blocks from your screenshot actually work? If so, impressive.
Not all... however this tutorial does not explain how to make them work, just how to get them to show. That is coming in part 2.
Offline
Hey, you're stickied!
Offline
I was going to say that...
Hooray! But I'm not planning to make any projects with it... just to be safe for 2.0.
Offline
Cool guide. Is there any way to make an in between () and () block? I've been looking for easy ways to do it but failing.
Offline
Stickman704 wrote:
Cool guide. Is there any way to make an in between () and () block? I've been looking for easy ways to do it but failing.
Yes. Simply test for whether it is less than the lesser number, and greater than the greater one.
This code does what you want:
number: t1 isBetween: t2 and: t3 ^ t1 >= t2 & (t1 <= t3)
Offline
billyedward, I have a question: How do you get the blocks you made to work?
Offline
Jonathanpb wrote:
billyedward, I have a question: How do you get the blocks you made to work?
Ok, open a system browser, select one of the three scriptable morphs, then select a category to put the function in. Next, delete the text in the bottommost pane and replace it with your method. For example:
openWindow: t1
| window |
window _ SystemWindow new.
window setLabel: t1 asString.
window openInWorld: World
Press alt + s, and now you can call this method from the blockSpecs
Last edited by nXIII (2010-02-27 20:37:39)
Offline
nXIII wrote:
Jonathanpb wrote:
billyedward, I have a question: How do you get the blocks you made to work?
Ok, open a system browser, select one of the three scriptable morphs, then select a category to put the function in. Next, delete the text in the bottommost pane and replace it with your method. For example:
openWindow: t1
| window |
window _ SystemWindow new.
window setLabel: t1 asString.
window openInWorld: WorldPress alt + s, and now you can call this method from the blockSpecs
THANK YOU SO MUCH!!!
Offline
Jonathanpb wrote:
billyedward, I have a question: How do you get the blocks you made to work?
That is a considerably more advanced thing. I made this topic as a guide to get totally new squeakers introduced to the squeak IDE, and the scratch source code.
In a nutshell, you want to make a function that matches the symbol specified in the block spec (the text followed by the #). Create it under scriptableScratchMorph > instance > appropriateOps. However, I will make part 2 or three of this guide series explain this.
Offline