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

#176 2010-05-02 10:59:38

randalpik
Scratcher
Registered: 2008-07-27
Posts: 82

Re: Cool custom blocks in Scratch

Sparkyasa wrote:

what should the specs be for a block that returns a boolean value that you enter: <<>>

%b


My stuff: http://scratch.mit.edu/users/randalpik
Your face: Look at a gopher

Offline

 

#177 2010-05-02 11:42:05

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Cool custom blocks in Scratch

randalpik wrote:

LS97 wrote:

2) ask nXIII. i'm also interested in this.

He says that we're all doing it wrong and blah blah blah and instead of deleting the rebuildCategorySelectors we should have added to it and blah blah blah. In conclusion, I will try to figure it out myself.

Um... OK then.

LS97 wrote:

hmm... nXIII, i know you're a great Squeaker and i love your show/hide list blocks, but why come onto this thread if you don't like the solutions i find? i'm not trying to make you go away, just saying that you're a bit too... know-it-all. "LS97 did this wrong, that wrong, do this, do that, do it my way it's the good way..."

anyway. where are the images stored?
by the way, i'm a he

I'm just trying to improve everyone's knowledge of Squeak and help you do things permanently. For example, if you crashed the Scratch frame while trying out a new block and then you deleted it to get rid of errors, when you create it again it won't have the buttons, and worse, it probably won't even work because you deleted a message that 'initialize' sends to its receiver.

Last edited by nXIII (2010-05-02 11:44:18)


nXIII

Offline

 

#178 2010-05-02 12:42:19

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Cool custom blocks in Scratch

nXIII wrote:

I'm just trying to improve everyone's knowledge of Squeak and help you do things permanently. For example, if you crashed the Scratch frame while trying out a new block and then you deleted it to get rid of errors, when you create it again it won't have the buttons, and worse, it probably won't even work because you deleted a message that 'initialize' sends to its receiver.

hmm... it's true that some blocks i have in Scratch that are in squeak don't work because of "findTokens:". what's that? and if you're so knowledgeable, could you add two categories to the rebuildSelectors called 'world' (in green) and 'files' (cyan) and post the code please? i'm desperate to make it work, even if it won't look as nice as i made it by dragging everything around :p

Offline

 

#179 2010-05-02 18:13:55

Joeman592
Scratcher
Registered: 2010-01-23
Posts: 100+

Re: Cool custom blocks in Scratch

LS97 wrote:

The key_pressed reporter block
a great block that saves you the fuss of making 30 scripts for each different key. just add this to a forever if and youre done with your scripting for a text program! add the block wherever you want, and add this code into the corresponding instance ops.

Code:

    (Sensor keyPressed: 65)
        ifTrue: [^ 'a'].
    (Sensor keyPressed: 66)
        ifTrue: [^ 'b'].
    (Sensor keyPressed: 67)
        ifTrue: [^ 'c'].
    (Sensor keyPressed: 68)
        ifTrue: [^ 'd'].
    (Sensor keyPressed: 69)
        ifTrue: [^ 'e'].
    (Sensor keyPressed: 70)
        ifTrue: [^ 'f'].
    (Sensor keyPressed: 71)
        ifTrue: [^ 'g'].
    (Sensor keyPressed: 72)
        ifTrue: [^ 'h'].
    (Sensor keyPressed: 73)
        ifTrue: [^ 'i'].
    (Sensor keyPressed: 74)
        ifTrue: [^ 'j'].
    (Sensor keyPressed: 75)
        ifTrue: [^ 'k'].
    (Sensor keyPressed: 76)
        ifTrue: [^ 'l'].
    (Sensor keyPressed: 77)
        ifTrue: [^ 'm'].
    (Sensor keyPressed: 78)
        ifTrue: [^ 'n'].
    (Sensor keyPressed: 79)
        ifTrue: [^ 'o'].
    (Sensor keyPressed: 80)
        ifTrue: [^ 'p'].
    (Sensor keyPressed: 81)
        ifTrue: [^ 'q'].
    (Sensor keyPressed: 82)
        ifTrue: [^ 'r'].
    (Sensor keyPressed: 83)
        ifTrue: [^ 's'].
    (Sensor keyPressed: 84)
        ifTrue: [^ 't'].
    (Sensor keyPressed: 85)
        ifTrue: [^ 'u'].
    (Sensor keyPressed: 86)
        ifTrue: [^ 'v'].
    (Sensor keyPressed: 87)
        ifTrue: [^ 'w'].
    (Sensor keyPressed: 88)
        ifTrue: [^ 'x'].
    (Sensor keyPressed: 89)
        ifTrue: [^ 'y'].
    (Sensor keyPressed: 90)
        ifTrue: [^ 'z'].
    (Sensor keyPressed: 32)
        ifTrue: [^ 'space'].
    (Sensor keyPressed: 1)
        ifTrue: [^ 'home'].
    (Sensor keyPressed: 4)
        ifTrue: [^ 'end'].
    (Sensor keyPressed: 5)
        ifTrue: [^ 'insert'].
    (Sensor keyPressed: 9)
        ifTrue: [^ 'tab'].
    (Sensor keyPressed: 11)
        ifTrue: [^ 'page up'].
    (Sensor keyPressed: 12)
        ifTrue: [^ 'page down'].
    (Sensor keyPressed: 127)
        ifTrue: [^ 'delete'].
    ^ 'none'

Pretty long eh? don't be discouraged it's worth it!

could you please make a blockspec for it? I don't know if it's ('key %s pressed' #b #code) or ('key pressed' #b #code), or if it's something else. I know you already did this but IDK if it's a reporter or a booolean or if it is suppored to have a string or not. Im just sortof confused

Last edited by Joeman592 (2010-05-02 18:15:22)


http://i.imgur.com/HcAj1.png
http://i.imgur.com/gss7S.gifhttp://i.imgur.com/kbcKt.gifhttp://i.imgur.com/0LteM.gif

Offline

 

#180 2010-05-02 23:38:27

Joeman592
Scratcher
Registered: 2010-01-23
Posts: 100+

Re: Cool custom blocks in Scratch

could you please help me with one little thing please? a (pen color) reporter block and a color picker reporter? please? it would be a HUGE help


http://i.imgur.com/HcAj1.png
http://i.imgur.com/gss7S.gifhttp://i.imgur.com/kbcKt.gifhttp://i.imgur.com/0LteM.gif

Offline

 

#181 2010-05-03 07:30:12

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Cool custom blocks in Scratch

Joeman592 wrote:

roger- wrote:

here's a good exponent block. put it under operators.

Code:

exp: t1 raisedTo: t2 
    | t3 |
    t3 _ t1 raisedTo: t2.
    ^ t3

But there isn't an operators... and if there is PLEASE TELL ME CUZ I CANT FIND IT! please? Also, please tell me if it goes in string.

Operators is the new name for numbers in 1.4


/* No comment */

Offline

 

#182 2010-05-03 08:05:52

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Cool custom blocks in Scratch

Joeman592 wrote:

LS97 wrote:

The key_pressed reporter block
a great block that saves you the fuss of making 30 scripts for each different key. just add this to a forever if and youre done with your scripting for a text program! add the block wherever you want, and add this code into the corresponding instance ops.

Code:

    (Sensor keyPressed: 65)
        ifTrue: [^ 'a'].
    (Sensor keyPressed: 66)
        ifTrue: [^ 'b'].
    (Sensor keyPressed: 67)
        ifTrue: [^ 'c'].
    (Sensor keyPressed: 68)
        ifTrue: [^ 'd'].
    (Sensor keyPressed: 69)
        ifTrue: [^ 'e'].
    (Sensor keyPressed: 70)
        ifTrue: [^ 'f'].
    (Sensor keyPressed: 71)
        ifTrue: [^ 'g'].
    (Sensor keyPressed: 72)
        ifTrue: [^ 'h'].
    (Sensor keyPressed: 73)
        ifTrue: [^ 'i'].
    (Sensor keyPressed: 74)
        ifTrue: [^ 'j'].
    (Sensor keyPressed: 75)
        ifTrue: [^ 'k'].
    (Sensor keyPressed: 76)
        ifTrue: [^ 'l'].
    (Sensor keyPressed: 77)
        ifTrue: [^ 'm'].
    (Sensor keyPressed: 78)
        ifTrue: [^ 'n'].
    (Sensor keyPressed: 79)
        ifTrue: [^ 'o'].
    (Sensor keyPressed: 80)
        ifTrue: [^ 'p'].
    (Sensor keyPressed: 81)
        ifTrue: [^ 'q'].
    (Sensor keyPressed: 82)
        ifTrue: [^ 'r'].
    (Sensor keyPressed: 83)
        ifTrue: [^ 's'].
    (Sensor keyPressed: 84)
        ifTrue: [^ 't'].
    (Sensor keyPressed: 85)
        ifTrue: [^ 'u'].
    (Sensor keyPressed: 86)
        ifTrue: [^ 'v'].
    (Sensor keyPressed: 87)
        ifTrue: [^ 'w'].
    (Sensor keyPressed: 88)
        ifTrue: [^ 'x'].
    (Sensor keyPressed: 89)
        ifTrue: [^ 'y'].
    (Sensor keyPressed: 90)
        ifTrue: [^ 'z'].
    (Sensor keyPressed: 32)
        ifTrue: [^ 'space'].
    (Sensor keyPressed: 1)
        ifTrue: [^ 'home'].
    (Sensor keyPressed: 4)
        ifTrue: [^ 'end'].
    (Sensor keyPressed: 5)
        ifTrue: [^ 'insert'].
    (Sensor keyPressed: 9)
        ifTrue: [^ 'tab'].
    (Sensor keyPressed: 11)
        ifTrue: [^ 'page up'].
    (Sensor keyPressed: 12)
        ifTrue: [^ 'page down'].
    (Sensor keyPressed: 127)
        ifTrue: [^ 'delete'].
    ^ 'none'

Pretty long eh? don't be discouraged it's worth it!

could you please make a blockspec for it? I don't know if it's ('key %s pressed' #b #code) or ('key pressed' #b #code), or if it's something else. I know you already did this but IDK if it's a reporter or a booolean or if it is suppored to have a string or not. Im just sortof confused

Use ('get key' #r #code)


/* No comment */

Offline

 

#183 2010-05-03 08:43:39

picklebobdogflog
Scratcher
Registered: 2010-01-24
Posts: 1

Re: Cool custom blocks in Scratch

Can you make a: if I receive ______ block?

Offline

 

#184 2010-05-03 11:07:26

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Cool custom blocks in Scratch

Joeman592 wrote:

could you please help me with one little thing please? a (pen color) reporter block and a color picker reporter? please? it would be a HUGE help

you do know that there are 225³ colors (approx 11 400 000) possible, don't you? that's why i can't make a color reporter that fits on one line. i can make the pen color one: ('pen hue' #r #penColor) should do the trick.

Last edited by LS97 (2010-05-03 11:59:08)

Offline

 

#185 2010-05-03 16:01:55

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Cool custom blocks in Scratch

LS97 wrote:

Joeman592 wrote:

could you please help me with one little thing please? a (pen color) reporter block and a color picker reporter? please? it would be a HUGE help

you do know that there are 225³ colors (approx 11 400 000) possible, don't you? that's why i can't make a color reporter that fits on one line. i can make the pen color one: ('pen hue' #r #penColor) should do the trick.

Well, you could use the Panther method:
http://i42.tinypic.com/24los4y.png


nXIII

Offline

 

#186 2010-05-03 20:48:59

randalpik
Scratcher
Registered: 2008-07-27
Posts: 82

Re: Cool custom blocks in Scratch

nXIII wrote:

Well, you could use the Panther method.

How do we do that? (I'm a noob at squeak, lol)


My stuff: http://scratch.mit.edu/users/randalpik
Your face: Look at a gopher

Offline

 

#187 2010-05-03 20:49:59

randalpik
Scratcher
Registered: 2008-07-27
Posts: 82

Re: Cool custom blocks in Scratch

LS97 wrote:

Joeman592 wrote:

could you please help me with one little thing please? a (pen color) reporter block and a color picker reporter? please? it would be a HUGE help

you do know that there are 225³ colors (approx 11 400 000) possible, don't you? that's why i can't make a color reporter that fits on one line. i can make the pen color one: ('pen hue' #r #penColor) should do the trick.

11,400,000 is only 8 digits. It should fit in a variable.


My stuff: http://scratch.mit.edu/users/randalpik
Your face: Look at a gopher

Offline

 

#188 2010-05-03 21:29:55

randalpik
Scratcher
Registered: 2008-07-27
Posts: 82

Re: Cool custom blocks in Scratch

I found the answer to our coloring problem! Just make all the buttons the same color!!! lol  tongue

EDIT: I feel like killing myself now. I've messed up the scratch viewer morph and I *saved* the image accidentally. DYE SELF NAO -----|- (that's a sword)

Last edited by randalpik (2010-05-03 21:46:42)


My stuff: http://scratch.mit.edu/users/randalpik
Your face: Look at a gopher

Offline

 

#189 2010-05-03 22:12:39

randalpik
Scratcher
Registered: 2008-07-27
Posts: 82

Re: Cool custom blocks in Scratch

nXIII wrote:

Sparkyasa wrote:

nXIII wrote:


um... asciiFor:

What's the Squeak code for it? And where should I put the code?

That's an already-existing message, if you don't want it to recognize things like 'space' then you have to make a new message
__________________________________________

randalpik wrote:

I got it a lot farther than before, but I have three questions:

1) how do you embed it in ScratchViewerMorph? When I save the image for end-user and reopen Scratch, the button disappears, although the code's still there.

2) how do you change the color of the button itself?

3) how do you make it so that the button is colored in when it's selected, and not colored in when it's not (like the other buttons)?

randalpik, I am REALLY recommending that you edit the message 'rebuildCategorySelectors' rather than listening to LS97 because he/she doesn't really know how to fix the layout and make the ScratchFrameMorph automatically rebuild itself WITH the new category. Here is my tutorial:
OK, first download ScratchSkin.zip and unzip it to the root folder. Next, copy three images of any category and rename them to your taste (dialogs, dialogsOver, dialogsPressed). Edit them using some color effect tool to make them whatever color you want.
Then reload the skin (see the comment in ScratchFrameMorph's readSkinFrom:).
Lastly, edit the 'rebuildCategorySelectors' method in ScratchViewerMorph and add an even number of categories to the catList definition.

All right, so I crashed my version of Scratch and had to start over. I'm following your instructions. But I couldn't find the message on how to reload the skin- can you help?


My stuff: http://scratch.mit.edu/users/randalpik
Your face: Look at a gopher

Offline

 

#190 2010-05-03 22:54:34

Joeman592
Scratcher
Registered: 2010-01-23
Posts: 100+

Re: Cool custom blocks in Scratch

randalpik wrote:

LS97 wrote:

Joeman592 wrote:

could you please help me with one little thing please? a (pen color) reporter block and a color picker reporter? please? it would be a HUGE help

you do know that there are 225³ colors (approx 11 400 000) possible, don't you? that's why i can't make a color reporter that fits on one line. i can make the pen color one: ('pen hue' #r #penColor) should do the trick.

11,400,000 is only 8 digits. It should fit in a variable.

I tried it, and it reports nil when it is clicked 3:

Last edited by Joeman592 (2010-05-03 22:56:08)


http://i.imgur.com/HcAj1.png
http://i.imgur.com/gss7S.gifhttp://i.imgur.com/kbcKt.gifhttp://i.imgur.com/0LteM.gif

Offline

 

#191 2010-05-04 13:23:48

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Cool custom blocks in Scratch

Joeman592 wrote:

I tried it, and it reports nil when it is clicked 3:

hm.. it should report 'Color blue'.... wierd.

Offline

 

#192 2010-05-04 13:43:01

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Cool custom blocks in Scratch

nXIII wrote:

Well, you could use the Panther method:

wow! that's a great method! but i'm just wondering, there's no existing block 'format' for it, i guess you had to create one. that's too much for me  smile  i guess i'll never be able to get even half as far as you guys have with Panther, you're so awesome! when's panther coming out (i know it's coming soon, no need to tell me THAT)

Offline

 

#193 2010-05-04 14:06:47

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Cool custom blocks in Scratch

LS97 wrote:

nXIII wrote:

Well, you could use the Panther method:

wow! that's a great method! but i'm just wondering, there's no existing block 'format' for it, i guess you had to create one. that's too much for me  smile  i guess i'll never be able to get even half as far as you guys have with Panther, you're so awesome! when's panther coming out (i know it's coming soon, no need to tell me THAT)

Hm... well, the release is being held up by a few things:
1) Moveable pen trails (stage has blocks for this)
2) Camera blocks
3) Other stuff I can't remember...

You're right that I had to make a new block class for the color reporters.


nXIII

Offline

 

#194 2010-05-04 20:09:03

Billybob-Mario
Scratcher
Registered: 2008-01-05
Posts: 500+

Re: Cool custom blocks in Scratch

nXIII wrote:

randalpik, I am REALLY recommending that you edit the message 'rebuildCategorySelectors' rather than listening to LS97 because he/she doesn't really know how to fix the layout and make the ScratchFrameMorph automatically rebuild itself WITH the new category. Here is my tutorial:
OK, first download ScratchSkin.zip and unzip it to the root folder. Next, copy three images of any category and rename them to your taste (dialogs, dialogsOver, dialogsPressed). Edit them using some color effect tool to make them whatever color you want.
Then reload the skin (see the comment in ScratchFrameMorph's readSkinFrom:).
Lastly, edit the 'rebuildCategorySelectors' method in ScratchViewerMorph and add an even number of categories to the catList definition.

How do you reload the skin?

Offline

 

#195 2010-05-04 20:27:34

Joeman592
Scratcher
Registered: 2010-01-23
Posts: 100+

Re: Cool custom blocks in Scratch

TheSuccessor wrote:

Joeman592 wrote:

roger- wrote:

here's a good exponent block. put it under operators.

Code:

exp: t1 raisedTo: t2 
    | t3 |
    t3 _ t1 raisedTo: t2.
    ^ t3

But there isn't an operators... and if there is PLEASE TELL ME CUZ I CANT FIND IT! please? Also, please tell me if it goes in string.

Operators is the new name for numbers in 1.4

yeah i meant in the source code


http://i.imgur.com/HcAj1.png
http://i.imgur.com/gss7S.gifhttp://i.imgur.com/kbcKt.gifhttp://i.imgur.com/0LteM.gif

Offline

 

#196 2010-05-04 20:51:43

randalpik
Scratcher
Registered: 2008-07-27
Posts: 82

Re: Cool custom blocks in Scratch

Joeman592 wrote:

TheSuccessor wrote:

Joeman592 wrote:


But there isn't an operators... and if there is PLEASE TELL ME CUZ I CANT FIND IT! please? Also, please tell me if it goes in string.

Operators is the new name for numbers in 1.4

yeah i meant in the source code

It's under ScratchSpriteMorph


My stuff: http://scratch.mit.edu/users/randalpik
Your face: Look at a gopher

Offline

 

#197 2010-05-04 21:30:04

Zorbak42
Scratcher
Registered: 2009-01-27
Posts: 100+

Re: Cool custom blocks in Scratch

nXIII wrote:

Sparkyasa wrote:

nXIII wrote:

um... asciiFor:

What's the Squeak code for it? And where should I put the code?

That's an already-existing message, if you don't want it to recognize things like 'space' then you have to make a new message
__________________________________________

randalpik wrote:

I got it a lot farther than before, but I have three questions:

1) how do you embed it in ScratchViewerMorph? When I save the image for end-user and reopen Scratch, the button disappears, although the code's still there.

2) how do you change the color of the button itself?

3) how do you make it so that the button is colored in when it's selected, and not colored in when it's not (like the other buttons)?

randalpik, I am REALLY recommending that you edit the message 'rebuildCategorySelectors' rather than listening to LS97 because he/she doesn't really know how to fix the layout and make the ScratchFrameMorph automatically rebuild itself WITH the new category. Here is my tutorial:
OK, first download ScratchSkin.zip and unzip it to the root folder. Next, copy three images of any category and rename them to your taste (dialogs, dialogsOver, dialogsPressed). Edit them using some color effect tool to make them whatever color you want.
Then reload the skin (see the comment in ScratchFrameMorph's readSkinFrom:).
Lastly, edit the 'rebuildCategorySelectors' method in ScratchViewerMorph and add an even number of categories to the catList definition.

Oops... Oh, that was bad... I just did this, and it's nice, my skin loaded except the extra block categories I made, but that's besides the point. I did it and, when I switch to the costumes/sounds tab in a sprite/stage, I get a squeak error. I'll edit the post with the error soon, I have to go soon. Please help, I had a lot of important stuff on my image file, and I saved it for end user. Thanks.
EDIT: The error is 'key not found'.
Another EDIT: Never mind, I fixed it (phew!) by loading in the normal skin.

Last edited by Zorbak42 (2010-05-05 06:53:54)

Offline

 

#198 2010-05-04 23:00:53

Joeman592
Scratcher
Registered: 2010-01-23
Posts: 100+

Re: Cool custom blocks in Scratch

randalpik wrote:

Joeman592 wrote:

TheSuccessor wrote:


Operators is the new name for numbers in 1.4

yeah i meant in the source code

It's under ScratchSpriteMorph

could you please give me thge steps of where to put it, and the blockspec, cuz it won't work


http://i.imgur.com/HcAj1.png
http://i.imgur.com/gss7S.gifhttp://i.imgur.com/kbcKt.gifhttp://i.imgur.com/0LteM.gif

Offline

 

#199 2010-05-05 11:28:30

randalpik
Scratcher
Registered: 2008-07-27
Posts: 82

Re: Cool custom blocks in Scratch

Joeman592 wrote:

randalpik wrote:

Joeman592 wrote:


yeah i meant in the source code

It's under ScratchSpriteMorph

could you please give me thge steps of where to put it, and the blockspec, cuz it won't work

Instead of scriptablescratchmorph, go to scratch sprite morph, to block specs, and to blockSpecs. and then go into instance and then to string ops


My stuff: http://scratch.mit.edu/users/randalpik
Your face: Look at a gopher

Offline

 

#200 2010-05-05 14:43:11

comp500
Scratcher
Registered: 2010-01-08
Posts: 1000+

Re: Cool custom blocks in Scratch

LS97 wrote:

The http://www.freeimagehosting.net/uploads/db8cb97ba8.gifblock
Another request of SeptimusHeap.
Put this code in both Sprite and Stage Morph blockSpecs in the sensing category:

Code:

 ('%s mouse down?' #b #mousePressed: 'left')

then into the instance, into ScriptableScratchMorph, and into 'sensing ops'.
replace the 'mousePressed' code with the one below.

Code:

mousePressed: t1 
    t1 = 'left' ifTrue: [^ Sensor redButtonPressed].
    t1 = 'right' ifTrue: [^ Sensor yellowButtonPressed].
    t1 = 'middle' ifTrue: [^ Sensor blueButtonPressed].
    t1 = 'any' ifTrue: [^ Sensor anyButtonPressed].
    t1 = 'left ' ifTrue: [^ Sensor redButtonPressed].
    t1 = 'right ' ifTrue: [^ Sensor yellowButtonPressed].
    t1 = 'middle ' ifTrue: [^ Sensor blueButtonPressed].
    t1 = 'any ' ifTrue: [^ Sensor anyButtonPressed].
    ^ Sensor redButtonPressed

Then click accept and it should be fine. you'll find the new block in the sensing category. you can put left, right, middle or any into the box and it'll give you the respective sensor button boolean.

Doesn't work  sad


800 posts! W00T! Oh sorry im not on a lot but at least i have 1000+ posts

Offline

 

Board footer