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:
nextCostume
self costumeIndex: self costumeIndex + 1By 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:
previousCostume
self costumeIndex: self costumeIndex - 1Now, 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:
$B = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #booleanAttributeNames;
choice: 'pen down?'].accept. Go to ScriptableScratchMorph and put under sensing ops:
booleanAttributeNames
^ #('has pen down?' 'is draggable?' 'is clone?' 'is visible?' 'is hidden?' ) collect: [:t1 | t1]accept. Now put:
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].
^ falseFinally, 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.


Last edited by Pecola1 (2011-05-21 08:57:27)
Offline
It should error if the mouse is chosen.
Offline
One question: Where is uncoloredArgMorphFor in the system browser?
Offline
jcpopp wrote:
One question: Where is uncoloredArgMorphFor in the system browser?
Scratch-Blocks » CommandBlockMorph » --all--/private » uncoloredArgMorphFor:
Offline
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.
Offline
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.
Offline
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.
![]()
LOL I remember,
, you don't have to remind me.
Offline
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.
![]()
LOL I remember,
, you don't have to remind me.
![]()
Is it still like that?
Offline
scimonster wrote:
Pecola1 wrote:
scimonster wrote:
That's right- Scimonster is right, not the R(oc)k(e)t system browser.![]()
LOL I remember,
, you don't have to remind me.
![]()
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.
Offline
Thanks! I was just looking around the chapters, and this looked very interesting, so I immediately started to make the block!!
Offline
jcpopp wrote:
Thanks! I was just looking around the chapters, and this looked very interesting, so I immediately started to make the block!!
![]()
You're welcome, have fun with Squeak! And have fun with that block.
Last edited by Pecola1 (2011-05-13 11:18:05)
Offline
Pecola1 wrote:
scimonster wrote:
Pecola1 wrote:
LOL I remember,, you don't have to remind me.
![]()
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.
![]()
The RKT Syst. Browser is fixed, in that part.
@Pecola1: You're.
Offline
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.
![]()
The RKT Syst. Browser is fixed, in that part.
@Pecola1: You're.![]()
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!!
![]()
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)
Offline
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.
![]()
The RKT Syst. Browser is fixed, in that part.
@Pecola1: You're.![]()
Where did I post your?
Post above that one.
Offline
scimonster wrote:
Pecola1 wrote:
scimonster wrote:
The RKT Syst. Browser is fixed, in that part.
@Pecola1: You're.![]()
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!
Offline
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?
BTW, keep the link in the sig, the one here.
Offline
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?
![]()
BTW, keep the link in the sig, the one here.![]()
Okay, uh.. what do you mean 'Misspellings'?
Offline
That's weird.....the previous costume block does not show up.
Offline
jcpopp wrote:
That's weird.....the previous costume block does not show up.
Did you accept?
Offline
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)
Offline
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?
Offline
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:
Offline
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.
Offline
Exactly, except on Scratch(not system browser) it does not show up with any of the other blocks.
Offline