Block tutorial
Welcome to this tutorial, which will help you make hacked blocks.
Chapter 0. Squeak?
Squeak! is the underlying programming language used to make Scratch. Scratch was made on a version of Squeak! slightly edited to meet Scratch's needs.
This chapter is under construction. Feedback appreciated!
==============
Chapter 1. System Browser
How-to:
On normal Scratch: Shift-click the R, and select Turn fill screen off. Now click the grey space that appears, select open then browser.
On source: It's already there for you.
==============
Chapter 1.5. What's the System Browser?
The system browser is where it stores all the code that makes Scratch work, and have the interface you see when you start Scratch. It also codes to view .sb projects as Scratch projects, which are required to do most of the file-involving functions.
All the skin etc. you see when you first start Scratch and all the ones that come into view if you click certain buttons are all programmed within the code. -- That's simple enough for this chapter.
==============
Chapter 2. What's the category lists?
The category lists are used for navigating to different code areas and methods.
These are handy for just about everything involving other methods and stuff in different areas.
It goes as 1>2>3>4. However, there are names for them.
Object Category > Objects > Method groups > Methods.
==============
Chapter 3. Instance and Class.
These, instance and class are not really needed but are there anyway, and can't be removed. Instance is where the block code goes, and Class is where the block specs to add the look of the block goes.
==============
Chapter 4. Blocks
Blocks are found in Scratch-Objects > [Class] ScratchSpriteMorph/ScratchStageMorph/ScriptableScratchMorph > Scratch (or Blockspecs) > Blockspecs.
The syntax for the blocks are:
('this is a block %s' #- #thisIsTheMethodNameInInstance:)
See how I highlighted it?
- The red represents all the block code inside it.
- The green represents the block label. %s creates a string input, and %n creates a number input.
- The blue represents the type of block, - means stack block, c means mouth-shaped blocks, r means reporter blocks, b means boolean blocks and s means special blocks.
- The purple represents the name of the code method the block executes.
The methods are located in Scratch-Objects > [Instance] ScratchSpriteMorph/ScratchStageMorph/ScriptableScratchMorph > [category] ops > thisIsTheMethodNameInInstance: t1.
On the block specs, and the title in the list do not have the t1 part. The t1 part is however used for the title of the actual coding, which represents the method name in creating a new method for a block.
===============
Chapter 4.5. The code of block instance methods
All the methods need text code. So all the commands are:
"Stack" commands:
| t1 t2 t4 thisisacustomvar | Declares all variables used in the scenario.
self _______ Executes the code, not needed with if's
[SpriteName] ______ Makes the sprite of that name do something. Works with Squeak sprites I think.
^ 'text or', 95, 'numbers or even', t1 asUTF8 asString, 'variables.' Makes the reporter block report what is given.
[condition here] ifTrue: [ ______ ] This one checks the condition, and if it is true, it does the code. An ifFalse: [ _____ ], ifNotNill: [ ______ ] or/and ifNill: [ ______ ] can be used instead of ifTrue: [ ____ ] aswell. You can do not nill and nill together, and also if false and if true together.
"Reporter" commands:
Unfinished -- I am learning Squeak Syntax too, and letting others learn the easy way from me with this topic. I think doing that is important.
[variable here] Reports a declared variable's value. For it's name, just do 'varname' with single quotes.
[something] asUTF8 asString [or the other way round, experiment!] Reports the something as a UTF8 and a String. Experiment with other asSomething's aswell! Different than ^ something -- it just tells the something to become UTF8 and String.
( 3402 rounded...) Rounds the number. Like the round block in Scratch.
"Boolean" commands:
Unfinished for same reason as above
something = 'this you can add vars', t1 asUTF8 asString Checks the condition and squeak-reports something based on the condition's value [true/false].
304 > 204 Same as above but not equal, but more than..
204 < 306 Same as above but with less than.
=================
Chapter 5. I want to know more.
Just tell me on this topic and I will add a chapter for this.
=================
Hope you like the tutorial.
Remember, I'm learning Squeak too, and letting others learn about it an easier way = by me telling them by me saying my knowledge of Squeak ifTrue: [ ^ 'Yay I can now make a mod off Scratch.' ]
It's rather amusing to see me use Squeak Syntax to type something.
So -- hope you like Squeak -- Oh, and this is only for the modified Squeak, targeting mostly on making blocks, but letting others know how to open the window to get to the code.
Please give me feedback on this enormo- Preivewed before posted, it wasn't large in size at all. That amused me.
Last edited by rdococ (2011-05-09 16:53:47)
Offline
rdococ wrote:
The syntax for the blocks are:
('this is a block %s #- #thisIsTheMethodNameInInstance:)
See how I highlighted it?
- The red represents all the block code inside it.
- The green represents the block label. %s creates a string input, and %n creates a number input.
- The blue represents the type of block, - means stack block, c means mouth-shaped blocks, r means reporter blocks, b means boolean blocks and s means special blocks.
- The purple represents the name of the code method the block executes.
The purple is called a selector. Also the blockspec should be
The syntax for the blocks are:
('this is a block %s' #- #thisIsTheMethodNameInInstance:)
You left out an '
Offline