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

#1 2011-04-25 20:58:42

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Squeak Smalltalk Chapter 5

So I promised to teach you how to make a C block. It can be simple, yet hard, let me first show you how to make a run block. It will be a simple, somewhat useless, run block, but it will teach you how to make a run block.
    The block looks like:
http://www.weebly.com/uploads/5/4/1/3/5413503/5687837.gif
    First, let me show you WHERE to put what. A C block is different from others, it needs to have its method somewhere else, Scratch-Execution Engine -> ScratchProcess -> private-special forms.
    Look at the 'doIf' method.

doIf
    | t1 t2 t3 |
    t1 _ stackFrame expression.
    t2 _ stackFrame arguments.
    t2 size = 0
        ifTrue:
            [t3 _ t1 argumentAt: 1.
            ^ self pushStackFrame: (ScratchStackFrame new expression: t3)].
    self popStackFrame.
    t2 first ifFalse: [^ self].
    self pushStackFrame: (ScratchStackFrame new expression: t1 firstBlockList)

Notice  the " t1 _ stackFrame expression." and "t2 _ stackFrame arguments." parts.  What does it mean? The stackFrame arguments is the inputs, in this case the boolean insert. The stackFrame expression is the C block, then stackFrame expression firstBlockList, is the blocks inserted in the first C, for the if else C block it is the top blocks, but you only need firstBlockList because of the if else block. (thanks to TheSuccessor for clarifying) Now look at " t2 first ifFalse: [^ self]." notice that you need to put t2 FIRST because there may be more than one insert.
    Now let's make the run block. The block spec is ('run' #c #doRun) . The method is simple, take out the t2 variable and any part containing it: ' t2 _ stackFrame arguments.', ' t2 size = 0
        ifTrue:
            [t3 _ t1 argumentAt: 1.
            ^ self pushStackFrame: (ScratchStackFrame new expression: t3)].' and ' t2 first ifFalse: [^ self].'. Now you can notice that t3 is no longer in the method, so remove that too! Finally replace 'doIf' with 'doRun'. You should turn out with:

doRun
    | t1 |
    t1 _ stackFrame expression.
    self popStackFrame.
    self pushStackFrame: (ScratchStackFrame new expression: t1 firstBlockList)

If you didn't replace your code with that and accept. Now I will show how this work. The simple way of saying it is, when in a C block, to run the blocks put:

t1 _ stackFrame expression.
    self popStackFrame.
    self pushStackFrame: (ScratchStackFrame new expression: t1 firstBlockList)

Also make sure you have a variable named t1 under the methods name.
    There is also an optional  thing you can do if your block may repeat more than once. It is adding the repeating arrow at the bottom. (It looks like _^ ) Go to Scratch-Blocks -> CBlockMorph -> private -> addCommandIcons. The method looks like so:

addCommandIcons
    | t1 |
    super addCommandIcons.
    (#(#doForever #doForeverIf #doRepeat #doUntil ) includes: selector)
        ifTrue:
            [t1 _ ScratchFrameMorph skinAt: #loopIcon ifAbsent: [^ self].
            loopMorph _ ImageMorph new form: t1.
            self addMorphBack: loopMorph]

Add the method name of your C block after '#doUntil' and remember to put a '#' before the method name.


http://www.weebly.com/uploads/5/4/1/3/5413503/3191070.gif
http://www.weebly.com/uploads/5/4/1/3/5413503/3967268.gif

Last edited by Pecola1 (2011-04-26 19:22:30)


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#2 2011-04-26 04:52:32

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

Oh, cool! You must really explore the System Browser to know all this.

Offline

 

#3 2011-04-26 04:56:55

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

could you make a 'c' 'boolean' block?

like [say](run
                    Script
run)


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#4 2011-04-26 04:58:52

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

ssss wrote:

could you make a 'c' 'boolean' block?

like [say](run
                    Script
run)

This is Scratch, not BYOB. I doubt it, they are completely different.  hmm

Offline

 

#5 2011-04-26 05:10:09

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

scimonster wrote:

ssss wrote:

could you make a 'c' 'boolean' block?

like [say](run
                    Script
run)

This is Scratch, not BYOB. I doubt it, they are completely different.  hmm

=_=

BYOB was based on Scratch -_-


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#6 2011-04-26 05:11:34

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

ssss wrote:

scimonster wrote:

ssss wrote:

could you make a 'c' 'boolean' block?

like [say](run
                    Script
run)

This is Scratch, not BYOB. I doubt it, they are completely different.  hmm

=_=

BYOB was based on Scratch -_-

I know, but Jens made it completely different.  They interpret basic things as obsolete blocks differently!

Offline

 

#7 2011-04-26 05:12:47

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

scimonster wrote:

ssss wrote:

scimonster wrote:


This is Scratch, not BYOB. I doubt it, they are completely different.  hmm

=_=

BYOB was based on Scratch -_-

I know, but Jens made it completely different.  They interpret basic things as obsolete blocks differently!

I wanted to do it for rocket


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#8 2011-04-26 05:26:24

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

ssss wrote:

scimonster wrote:

ssss wrote:

=_=

BYOB was based on Scratch -_-

I know, but Jens made it completely different.  They interpret basic things as obsolete blocks differently!

I wanted to do it for rocket

Bug Jens or copy the source.
EDIT: 2050posts.

Last edited by scimonster (2011-04-26 05:29:06)

Offline

 

#9 2011-04-26 05:33:59

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

scimonster wrote:

ssss wrote:

scimonster wrote:


I know, but Jens made it completely different.  They interpret basic things as obsolete blocks differently!

I wanted to do it for rocket

Bug Jens or copy the source.
EDIT: 2050posts.

K, i suppose bugging jens could work -_-

Or hacking BYOB - which is way to easy  big_smile


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#10 2011-04-26 06:38:27

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

ssss wrote:

scimonster wrote:

ssss wrote:


I wanted to do it for rocket

Bug Jens or copy the source.
EDIT: 2050posts.

K, i suppose bugging jens could work -_-

Or hacking BYOB - which is way to easy  big_smile

Yes, it is.  But hacking Scratch is very easy too.  wink

Offline

 

#11 2011-04-26 06:46:52

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

scimonster wrote:

ssss wrote:

scimonster wrote:


Bug Jens or copy the source.
EDIT: 2050posts.

K, i suppose bugging jens could work -_-

Or hacking BYOB - which is way to easy  big_smile

Yes, it is.  But hacking Scratch is very easy too.  wink

Hacking hacked hacked source is easiest


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#12 2011-04-26 06:51:02

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

bbbeb wrote:

scimonster wrote:

ssss wrote:


K, i suppose bugging jens could work -_-

Or hacking BYOB - which is way to easy  big_smile

Yes, it is.  But hacking Scratch is very easy too.  wink

Hacking hacked hacked source is easiest

-_-


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#13 2011-04-26 06:52:31

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

bbbeb wrote:

scimonster wrote:

ssss wrote:


K, i suppose bugging jens could work -_-

Or hacking BYOB - which is way to easy  big_smile

Yes, it is.  But hacking Scratch is very easy too.  wink

Hacking hacked hacked source is easiest

hackHhackohackwhack?hack

Offline

 

#14 2011-04-26 06:53:48

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

scimonster wrote:

bbbeb wrote:

scimonster wrote:


Yes, it is.  But hacking Scratch is very easy too.  wink

Hacking hacked hacked source is easiest

hackHhackohackwhack?hack

The more u guys talk to me, the further Rocket is pushed away.  Hurry up and gimme good suggestions =_=


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#15 2011-04-26 06:55:10

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

ssss wrote:

scimonster wrote:

bbbeb wrote:

Hacking hacked hacked source is easiest

hackHhackohackwhack?hack

The more u guys talk to me, the further Rocket is pushed away.  Hurry up and gimme good suggestions =_=

OK. Are you working on RKT Compare?
*clicks to play 60sr game*

Offline

 

#16 2011-04-26 06:56:18

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

scimonster wrote:

ssss wrote:

scimonster wrote:


hackHhackohackwhack?hack

The more u guys talk to me, the further Rocket is pushed away.  Hurry up and gimme good suggestions =_=

OK. Are you working on RKT Compare?
*clicks to play 60sr game*

Sorry, that's what Pecola1 was doing.  I had nothing to do with that development =_=


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#17 2011-04-26 07:01:10

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

ssss wrote:

scimonster wrote:

ssss wrote:


The more u guys talk to me, the further Rocket is pushed away.  Hurry up and gimme good suggestions =_=

OK. Are you working on RKT Compare?
*clicks to play 60sr game*

Sorry, that's what Pecola1 was doing.  I had nothing to do with that development =_=

Oh. =_=

How about an [import {|costume/sound/sprite|} from [file location]] block?

Offline

 

#18 2011-04-26 07:04:07

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

This is a really good tutorial!
BTW, If Panther ends up not liking me, I'll come back.

Offline

 

#19 2011-04-26 07:04:21

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

scimonster wrote:

ssss wrote:

scimonster wrote:

OK. Are you working on RKT Compare?
*clicks to play 60sr game*

Sorry, that's what Pecola1 was doing.  I had nothing to do with that development =_=

Oh. =_=

How about an [import {|costume/sound/sprite|} from [file location]] block?

Yes, that was what i was working on -_=

-s-i-x-t-y-s-e-c-ol-n-d-r-u-l-e-g-a-m-e-


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#20 2011-04-26 14:20:19

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

ProgrammingFreak wrote:

This is a really good tutorial!
BTW, If Panther ends up not liking me, I'll come back.

I hope they don't li... er... I mean... I hope you come back and qui... well... I just hope you will have time to help when we need you, you are still considered a dev, to me. I doubt we will finish it soon.


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#21 2011-04-26 14:22:05

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

Pecola1 wrote:

ProgrammingFreak wrote:

This is a really good tutorial!
BTW, If Panther ends up not liking me, I'll come back.

I hope they don't li... er... I mean... I hope you come back and qui... well... I just hope you will have time to help when we need you, you are still considered a dev, to me. I doubt we will finish it soon.

Well, I don't know. To tell you the truth, they are kinda lazy.  tongue  Not entirely. Its just slow ever since nXII left.

I wanna tell you a secret. Just wait for a message....

edit: sent it.

Last edited by ProgrammingFreak (2011-04-26 14:25:20)

Offline

 

#22 2011-04-26 14:25:11

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

ProgrammingFreak wrote:

Pecola1 wrote:

ProgrammingFreak wrote:

This is a really good tutorial!
BTW, If Panther ends up not liking me, I'll come back.

I hope they don't li... er... I mean... I hope you come back and qui... well... I just hope you will have time to help when we need you, you are still considered a dev, to me. I doubt we will finish it soon.

Well, I don't know. To tell you the truth, they are kinda lazy.  tongue  Not entirely. Its just slow ever since nXII left.

I wanna tell you a secret. Just wait for a message....

I had no idea nXII left! He was the main programmer wasn't he? They can't be as lazy procrastinators as RKT devs are, we haven't even started on the new img! LOL


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#23 2011-04-26 14:26:15

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

Pecola1 wrote:

ProgrammingFreak wrote:

Pecola1 wrote:


I hope they don't li... er... I mean... I hope you come back and qui... well... I just hope you will have time to help when we need you, you are still considered a dev, to me. I doubt we will finish it soon.

Well, I don't know. To tell you the truth, they are kinda lazy.  tongue  Not entirely. Its just slow ever since nXII left.

I wanna tell you a secret. Just wait for a message....

I had no idea nXII left! He was the main programmer wasn't he? They can't be as lazy procrastinators as RKT devs are, we haven't even started on the new img! LOL

big_smile

Sent the message...

Offline

 

#24 2011-04-26 14:31:31

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: Squeak Smalltalk Chapter 5

ProgrammingFreak wrote:

Pecola1 wrote:

ProgrammingFreak wrote:

Well, I don't know. To tell you the truth, they are kinda lazy.  tongue  Not entirely. Its just slow ever since nXII left.

I wanna tell you a secret. Just wait for a message....

I had no idea nXII left! He was the main programmer wasn't he? They can't be as lazy procrastinators as RKT devs are, we haven't even started on the new img! LOL

big_smile

Sent the message...

You must be kidding me! Really you forgot your middle name! JK LOL XD
(that wasn't the secret PF told me BTW, it isn't trust me!) he will kill me if you know that was it. Uh... not literally kill me....


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#25 2011-04-26 14:37:35

xIIV
New Scratcher
Registered: 2010-12-04
Posts: 72

Re: Squeak Smalltalk Chapter 5

Pecola1 wrote:

ProgrammingFreak wrote:

Pecola1 wrote:


I had no idea nXII left! He was the main programmer wasn't he? They can't be as lazy procrastinators as RKT devs are, we haven't even started on the new img! LOL

big_smile

Sent the message...

You must be kidding me! Really you forgot your middle name! JK LOL XD
(that wasn't the secret PF told me BTW, it isn't trust me!) he will kill me if you know that was it. Uh... not literally kill me....

People do forget their middle names sometimes. So, I'm back. I'll post in the new 'Rocket' forum.


Helping helps others to help you.  wink

Offline

 

Board footer