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

#1 2011-04-24 10:45:43

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

Squeak Smalltalk Chapter 4

Now I will show you how to make a simple block, the [previous costume]  block. First I will show you the [next costume]  block's code so you can get the feel of how this works. Go to ScratchScratchMorph -> [instance] -> looks ops -> nextCostume, the code is:

Code:

 nextCostume
    self costumeIndex: self costumeIndex + 1

By that you can probably tell it simply is [switch to costume ((costume #)) + ( 1 ) )] and since you know how to make a BYOB block previous costume block, you can easily make a method by reversing the next costume method. Let's see... since the next costume block works by switching (or setting costume index by using self costumeIndex: ) to the costume # (which is self costumeIndex) + 1 (the + 1 part which is too obvious), then why not use switch to costume costume # - 1! The code: self costumeIndex: (switch to costume) self costumeIndex (costume #) - 1 (U Know What), in simple you can use this code:

Code:

previousCostume
    self costumeIndex: self costumeIndex - 1

Now, under blockSpecs put

('previous costume' #- #previousCostume)

That is the first command block you have made using this tutorial! Now I will show you how to make a < { ^} for { ^} >  block. Stumped? This block is like the ({ ^} of { ^})  block, only it reports the booleans of another sprite! You can see if the other sprite is draggable, has pen down, is a clone, is visible or is hidden! First go to uncoloredArgMorphFor: and add the strip:

Code:

 $B = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #booleanAttributeNames;
         choice: 'pen down?'].

accept. Go to ScriptableScratchMorph and put under sensing ops:

Code:

 booleanAttributeNames
    ^ #('has pen down?' 'is draggable?' 'is clone?' 'is visible?' 'is hidden?' ) collect: [:t1 | t1]

accept. Now put:

Code:

 getBooleanAttribute: t1 for: t3 
    | t2 |
    (vars includesKey: t1)
        ifTrue: [^ vars at: t1].
    t2 _ t1 localized.
    'has pen down?' localized = t2 ifTrue: [^ t3 penDown].
    'is draggable?' localized = t2 ifTrue: [^ t3 isDraggable].
    'is clone?' localized = t2 ifTrue: [^ t3 isClone].
    'is visible?' localized = t2 ifTrue: [^ t3 isVisible].
    'is hidden?' localized = t2 ifTrue: [^ t3 isHidden].
    ^ false

Finally, under blockSpecs put

('%B for %m' #b #getBooleanAttribute:for:)

How does this block work? It simply uses a special way in squeak smalltalk which allows it to see another sprite/morph's methods. So what it does is it looks on whatever sprite is inserted's method, for whatever the first insert is, which reports true or false.  Now of course mouse pointer doesn't have these booleans so do not select mouse-pointer on the second insert. If you want to see if the sprite you are on is draggable, or is a clone, simply put the join block inside the sprite insert and put the sprites name. (e.g. < { is draggable^} for {(join [] [Sprite1)} >
    Next chapter will be one you can't get anywhere else! How to make a C shaped block! Very few people know how and I am one of them and you can be too.


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

Last edited by Pecola1 (2011-05-21 08:57:27)


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-25 07:15:16

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

Re: Squeak Smalltalk Chapter 4

Yay!  wink

Offline

 

#3 2011-04-26 04:50:15

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

Re: Squeak Smalltalk Chapter 4

It should error if the mouse is chosen.

Offline

 

#4 2011-05-11 21:09:23

jcpopp
Scratcher
Registered: 2010-10-30
Posts: 100+

Re: Squeak Smalltalk Chapter 4

One question: Where is uncoloredArgMorphFor in the system browser?


Join Nitro Type! It really improves your typing skills  big_smile

Offline

 

#5 2011-05-12 00:42:01

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

Re: Squeak Smalltalk Chapter 4

jcpopp wrote:

One question: Where is uncoloredArgMorphFor in the system browser?

Scratch-Blocks » CommandBlockMorph » --all--/private » uncoloredArgMorphFor:

Offline

 

#6 2011-05-12 14:59:13

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

Re: Squeak Smalltalk Chapter 4

jcpopp wrote:

One question: Where is uncoloredArgMorphFor in the system browser?

Scimonster is right, I didn't put it on because it was in the third chapter, I should put it in the first chap.


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

 

#7 2011-05-12 15:06:02

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

Re: Squeak Smalltalk Chapter 4

Pecola1 wrote:

jcpopp wrote:

One question: Where is uncoloredArgMorphFor in the system browser?

Scimonster is right, I didn't put it on because it was in the third chapter, I should put it in the first chap.

That's right- Scimonster is right, not the R(oc)k(e)t system browser.  tongue

Offline

 

#8 2011-05-12 15:07:49

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

Re: Squeak Smalltalk Chapter 4

scimonster wrote:

Pecola1 wrote:

jcpopp wrote:

One question: Where is uncoloredArgMorphFor in the system browser?

Scimonster is right, I didn't put it on because it was in the third chapter, I should put it in the first chap.

That's right- Scimonster is right, not the R(oc)k(e)t system browser.  tongue

LOL I remember,  roll , you don't have to remind me.  tongue


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

 

#9 2011-05-12 15:10:20

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

Re: Squeak Smalltalk Chapter 4

Pecola1 wrote:

scimonster wrote:

Pecola1 wrote:

Scimonster is right, I didn't put it on because it was in the third chapter, I should put it in the first chap.

That's right- Scimonster is right, not the R(oc)k(e)t system browser.  tongue

LOL I remember,  roll , you don't have to remind me.  tongue

Is it still like that?

Offline

 

#10 2011-05-12 15:17:08

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

Re: Squeak Smalltalk Chapter 4

scimonster wrote:

Pecola1 wrote:

scimonster wrote:


That's right- Scimonster is right, not the R(oc)k(e)t system browser.  tongue

LOL I remember,  roll , you don't have to remind me.  tongue

Is it still like that?

What still like what? The RKT system browser? Or my chapter? I fixed it in my chapter, and in the RKT browser it wont be soon, we had to re-restart.  tongue


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

 

#11 2011-05-12 19:48:44

jcpopp
Scratcher
Registered: 2010-10-30
Posts: 100+

Re: Squeak Smalltalk Chapter 4

Thanks!  I was just looking around the chapters, and this looked very interesting, so I immediately started to make the block!!   big_smile


Join Nitro Type! It really improves your typing skills  big_smile

Offline

 

#12 2011-05-12 19:53:22

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

Re: Squeak Smalltalk Chapter 4

jcpopp wrote:

Thanks!  I was just looking around the chapters, and this looked very interesting, so I immediately started to make the block!!   big_smile

You're welcome, have fun with Squeak! And have fun with that block.

Last edited by Pecola1 (2011-05-13 11:18:05)


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

 

#13 2011-05-12 23:08:19

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

Re: Squeak Smalltalk Chapter 4

Pecola1 wrote:

scimonster wrote:

Pecola1 wrote:


LOL I remember,  roll , you don't have to remind me.  tongue

Is it still like that?

What still like what? The RKT system browser? Or my chapter? I fixed it in my chapter, and in the RKT browser it wont be soon, we had to re-restart.  tongue

The RKT Syst. Browser is fixed, in that part.
@Pecola1: You'rewink

Offline

 

#14 2011-05-13 11:17:29

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

Re: Squeak Smalltalk Chapter 4

scimonster wrote:

Pecola1 wrote:

scimonster wrote:

Is it still like that?

What still like what? The RKT system browser? Or my chapter? I fixed it in my chapter, and in the RKT browser it wont be soon, we had to re-restart.  tongue

The RKT Syst. Browser is fixed, in that part.
@Pecola1: You'rewink

Where did I post your?
EDIT:
Oh, you're correct, he doesn't own welcome!


Pecola1 wrote:

jcpopp wrote:

Thanks!  I was just looking around the chapters, and this looked very interesting, so I immediately started to make the block!!   big_smile

Your welcome, have fun with Squeak! And have fun with that block.

I edited it now, that better? LOL

Last edited by Pecola1 (2011-05-13 11:19:42)


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

 

#15 2011-05-13 11:19:17

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

Re: Squeak Smalltalk Chapter 4

Pecola1 wrote:

scimonster wrote:

Pecola1 wrote:

What still like what? The RKT system browser? Or my chapter? I fixed it in my chapter, and in the RKT browser it wont be soon, we had to re-restart.  tongue

The RKT Syst. Browser is fixed, in that part.
@Pecola1: You'rewink

Where did I post your?

Post above that one.

Offline

 

#16 2011-05-13 11:22:11

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

Re: Squeak Smalltalk Chapter 4

scimonster wrote:

Pecola1 wrote:

scimonster wrote:


The RKT Syst. Browser is fixed, in that part.
@Pecola1: You'rewink

Where did I post your?

Post above that one.

We posted at almost the EXACT SAME TIME! When I posted I went beck two tne Advenced Topix, and lookd at tha top post and it said scrimonster posted last!


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

 

#17 2011-05-13 11:25:09

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

Re: Squeak Smalltalk Chapter 4

Pecola1 wrote:

scimonster wrote:

Pecola1 wrote:


Where did I post your?

Post above that one.

We posted at almost the EXACT SAME TIME! When I posted I went beck two tne Advenced Topix, and lookd at tha top post and it said scrimonster posted last!

Misspellings on purpose?  tongue
BTW, keep the link in the sig, the one herebig_smile

Offline

 

#18 2011-05-13 11:31:08

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

Re: Squeak Smalltalk Chapter 4

scimonster wrote:

Pecola1 wrote:

scimonster wrote:


Post above that one.

We posted at almost the EXACT SAME TIME! When I posted I went beck two tne Advenced Topix, and lookd at tha top post and it said scrimonster posted last!

Misspellings on purpose?  tongue
BTW, keep the link in the sig, the one herebig_smile

Okay, uh.. what do you mean 'Misspellings'?


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

 

#19 2011-05-14 12:19:06

jcpopp
Scratcher
Registered: 2010-10-30
Posts: 100+

Re: Squeak Smalltalk Chapter 4

That's weird.....the previous costume block does not show up.


Join Nitro Type! It really improves your typing skills  big_smile

Offline

 

#20 2011-05-14 19:58:50

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

Re: Squeak Smalltalk Chapter 4

jcpopp wrote:

That's weird.....the previous costume block does not show up.

Did you accept?


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-05-15 10:28:47

jcpopp
Scratcher
Registered: 2010-10-30
Posts: 100+

Re: Squeak Smalltalk Chapter 4

Pecola1 wrote:

jcpopp wrote:

That's weird.....the previous costume block does not show up.

Did you accept?

I did accept, and it showed up on the very right, where the next costume block was. D:

Last edited by jcpopp (2011-05-15 10:29:49)


Join Nitro Type! It really improves your typing skills  big_smile

Offline

 

#22 2011-05-15 14:28:59

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

Re: Squeak Smalltalk Chapter 4

jcpopp wrote:

Pecola1 wrote:

jcpopp wrote:

That's weird.....the previous costume block does not show up.

Did you accept?

I did accept, and it showed up on the very right, where the next costume block was. D:

And what is wrong with this?


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-05-15 17:30:17

jcpopp
Scratcher
Registered: 2010-10-30
Posts: 100+

Re: Squeak Smalltalk Chapter 4

Pecola1 wrote:

jcpopp wrote:

Pecola1 wrote:


Did you accept?

I did accept, and it showed up on the very right, where the next costume block was. D:

And what is wrong with this?

It shows up on the system browser, but not on scratch (where all the blocks are).
D:


Join Nitro Type! It really improves your typing skills  big_smile

Offline

 

#24 2011-05-15 19:29:56

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

Re: Squeak Smalltalk Chapter 4

jcpopp wrote:

Pecola1 wrote:

jcpopp wrote:


I did accept, and it showed up on the very right, where the next costume block was. D:

And what is wrong with this?

It shows up on the system browser, but not on scratch (where all the blocks are).
D:

Oh so: "I did accept, and it showed up on the very right, where the next costume block was." was referring to the system browser.


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-05-16 07:38:09

jcpopp
Scratcher
Registered: 2010-10-30
Posts: 100+

Re: Squeak Smalltalk Chapter 4

Exactly, except on Scratch(not system browser) it does not show up with any of the other blocks.


Join Nitro Type! It really improves your typing skills  big_smile

Offline

 

Board footer