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

#51 2010-04-19 19:45:04

Jakey22
Scratcher
Registered: 2008-12-28
Posts: 72

Re: Cool custom blocks in Scratch

nXIII wrote:

Jakey22 wrote:

Please do the dialog block next. Thanks!

Why are you asking for blocks with existing tutorials?

Where is the tutorial?

Last edited by Jakey22 (2010-04-19 19:45:57)


http://www.imagebookers.com/gallery/d/2561-1/ubuntu-wallpaper.png http://bullylug.org/linux-penguin.jpg
My website       PENGUINS!!!!!!!!!!!!!!!!!!!!! randomness.

Offline

 

#52 2010-04-19 20:06:44

Jakey22
Scratcher
Registered: 2008-12-28
Posts: 72

Re: Cool custom blocks in Scratch

Never mind I found it: here.


http://www.imagebookers.com/gallery/d/2561-1/ubuntu-wallpaper.png http://bullylug.org/linux-penguin.jpg
My website       PENGUINS!!!!!!!!!!!!!!!!!!!!! randomness.

Offline

 

#53 2010-04-19 20:28:13

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Cool custom blocks in Scratch

Awesome. Brilliant! :d


Hai.

Offline

 

#54 2010-04-20 06:51:44

manuke
Scratcher
Registered: 2009-08-25
Posts: 3

Re: Cool custom blocks in Scratch

i would like a (touched color) block.
i would report the color that he's touching at the same scale as the block[blocks] <change[  ]effect by( [/blocks](scale 0-200)

Offline

 

#55 2010-04-20 06:53:09

manuke
Scratcher
Registered: 2009-08-25
Posts: 3

Re: Cool custom blocks in Scratch

[block] <change[ color ]effect by(0) [/block]

Offline

 

#56 2010-04-20 10:44:39

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

Re: Cool custom blocks in Scratch

manuke wrote:

i would like a (touched color) block.
i would report the color that he's touching at the same scale as the block[blocks] <change[  ]effect by( [/blocks](scale 0-200)

That would not be possible as the sprite is more than one pixel, so the colors it is touching could be more than one. i can still try to make it work for a 1@1 sprite, but i can't guarantee any results.

EDIT: my knowledge does not go far enough for your block. i can't figure anything out.

Last edited by LS97 (2010-04-20 10:50:40)

Offline

 

#57 2010-04-20 11:37:16

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

Re: Cool custom blocks in Scratch

LS97 wrote:

The link block
Ok, finally some time to add the greatest block of all. the block links the user to a webpage, program or file as long as the path  or URL is given. add in the blockspecs in the control section some kind of block code (choose whatever you want, you know how to do it). and add in the corresponding instance ops:

Code:

    Cursor wait showWhile: [ScratchPlugin primOpenURL: t1]

So little code for such a great block... and remember to click accept!

For people who aren't sure how to put this in the block specs, here's a good way:

Code:

 ('go to website %s' #- #getLink: 'http://scratch.mit.edu/')

The result will be a block that says "go to website [http://scratch.mit.edu/]" wherein scratch.mit.edu is what it says by default.


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

Offline

 

#58 2010-04-20 11:42:01

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

Re: Cool custom blocks in Scratch

randalpik wrote:

LS97 wrote:

The link block
Ok, finally some time to add the greatest block of all. the block links the user to a webpage, program or file as long as the path  or URL is given. add in the blockspecs in the control section some kind of block code (choose whatever you want, you know how to do it). and add in the corresponding instance ops:

Code:

    Cursor wait showWhile: [ScratchPlugin primOpenURL: t1]

So little code for such a great block... and remember to click accept!

For people who aren't sure how to put this in the block specs, here's a good way:

Code:

 ('go to website %s' #- #getLink: 'http://scratch.mit.edu/')

The result will be a block that says "go to website [http://scratch.mit.edu/]" wherein scratch.mit.edu is what it says by default.

That's a good block spec, but i would say 'link to' instead of 'go to site' because the block does not only link to sites but also to programs.

Offline

 

#59 2010-04-20 11:47:38

manuke
Scratcher
Registered: 2009-08-25
Posts: 3

Re: Cool custom blocks in Scratch

LS97 wrote:

manuke wrote:

i would like a (touched color) block.
i would report the color that he's touching at the same scale as the block[blocks] <change[  ]effect by( [/blocks](scale 0-200)

That would not be possible as the sprite is more than one pixel, so the colors it is touching could be more than one. i can still try to make it work for a 1@1 sprite, but i can't guarantee any results.

EDIT: my knowledge does not go far enough for your block. i can't figure anything out.

well if you can do it for a 1@1 sprite i would like it very much and hope you can do it

Offline

 

#60 2010-04-20 11:47:44

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

Re: Cool custom blocks in Scratch

LS97 wrote:

The 'showing?' block
This is an easy one. It gives a boolean response (True/False) of whether the sprite is showing or not.
Like before, copy this code into the 'looks' section of blockSpecs in ScratchSpriteMorph

Code:

('showing?' #b #getHidden)

then go to instance, 'looks ops' and replace the code in 'hide' with the code below (by the way, you're not deleting the hide block).

Code:

getHidden
    self isHidden = false ifTrue: [^ true].
    ^ false

Then right-click, clik accept and (maybe) type your initials. et voilà, you have your 'showing?' block up and ready.

You can also get a "hidden?" block like this:

Go to the blockSpecs based on the instructions above (by ls97) and add this:

Code:

('hidden?' #b #getShowing)

Go to instance, click on "looks ops" and in the main screen add this code:

Code:

getShowing
    self isHidden = false ifTrue: [^ false].
    ^ true

Hope that's helpful!


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

Offline

 

#61 2010-04-20 11:49:19

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

Re: Cool custom blocks in Scratch

LS97 wrote:

randalpik wrote:

LS97 wrote:

The link block
Ok, finally some time to add the greatest block of all. the block links the user to a webpage, program or file as long as the path  or URL is given. add in the blockspecs in the control section some kind of block code (choose whatever you want, you know how to do it). and add in the corresponding instance ops:

Code:

    Cursor wait showWhile: [ScratchPlugin primOpenURL: t1]

So little code for such a great block... and remember to click accept!

For people who aren't sure how to put this in the block specs, here's a good way:

Code:

 ('go to website %s' #- #getLink: 'http://scratch.mit.edu/')

The result will be a block that says "go to website [http://scratch.mit.edu/]" wherein scratch.mit.edu is what it says by default.

That's a good block spec, but i would say 'link to' instead of 'go to site' because the block does not only link to sites but also to programs.

That's true.


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

Offline

 

#62 2010-04-20 11:51:27

Sperry
Scratcher
Registered: 2010-03-09
Posts: 500+

Re: Cool custom blocks in Scratch

randalpik wrote:

LS97 wrote:

The 'showing?' block
This is an easy one. It gives a boolean response (True/False) of whether the sprite is showing or not.
Like before, copy this code into the 'looks' section of blockSpecs in ScratchSpriteMorph

Code:

('showing?' #b #getHidden)

then go to instance, 'looks ops' and replace the code in 'hide' with the code below (by the way, you're not deleting the hide block).

Code:

getHidden
    self isHidden = false ifTrue: [^ true].
    ^ false

Then right-click, clik accept and (maybe) type your initials. et voilà, you have your 'showing?' block up and ready.

You can also get a "hidden?" block like this:

Go to the blockSpecs based on the instructions above (by ls97) and add this:

Code:

('hidden?' #b #getShowing)

Go to instance, click on "looks ops" and in the main screen add this code:

Code:

getShowing
    self isHidden = false ifTrue: [^ false].
    ^ true

Hope that's helpful!

Theres a easier way than that!
Just use ('Hidden?' #b #isHidden)


http://img709.imageshack.us/img709/3252/gobanim2.gifhttp://ls.gd/bo

Offline

 

#63 2010-04-20 11:55:40

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

Re: Cool custom blocks in Scratch

Sperry wrote:

randalpik wrote:

LS97 wrote:

The 'showing?' block
This is an easy one. It gives a boolean response (True/False) of whether the sprite is showing or not.
Like before, copy this code into the 'looks' section of blockSpecs in ScratchSpriteMorph

Code:

('showing?' #b #getHidden)

then go to instance, 'looks ops' and replace the code in 'hide' with the code below (by the way, you're not deleting the hide block).

Code:

getHidden
    self isHidden = false ifTrue: [^ true].
    ^ false

Then right-click, clik accept and (maybe) type your initials. et voilà, you have your 'showing?' block up and ready.

You can also get a "hidden?" block like this:

Go to the blockSpecs based on the instructions above (by ls97) and add this:

Code:

('hidden?' #b #getShowing)

Go to instance, click on "looks ops" and in the main screen add this code:

Code:

getShowing
    self isHidden = false ifTrue: [^ false].
    ^ true

Hope that's helpful!

Theres a easier way than that!
Just use ('Hidden?' #b #isHidden)

*Facepalm* I should have thought of that.


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

Offline

 

#64 2010-04-20 11:56:41

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

Re: Cool custom blocks in Scratch

Sperry wrote:

Theres a easier way than that!
Just use ('Hidden?' #b #isHidden)

Yeah i know but as the red note in the first post says, this is a tutorial and somewhat going into the code further encourages learning.

Offline

 

#65 2010-04-20 12:06:29

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

Re: Cool custom blocks in Scratch

I now found out the code for "import image and wait"!
It's exactly as easy as the "save stage area to sprite" block.

All you have to do is add this in the looks section ofScratchSpriteMorph --> block specs --> blockSpecs:

('import image and wait' #- #importImage)

And that's it!


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

Offline

 

#66 2010-04-20 12:10:38

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

Re: Cool custom blocks in Scratch

randalpik wrote:

I now found out the code for "import image and wait"!
It's exactly as easy as the "save stage area to sprite" block.

All you have to do is add this in the looks section ofScratchSpriteMorph --> block specs --> blockSpecs:

('import image and wait' #- #importImage)

And that's it!

yup! thanks for adding a block tutorial you saved me a post

Offline

 

#67 2010-04-20 12:50:33

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

Re: Cool custom blocks in Scratch

Ok, I got 2 more blocks.

Make a Variable- makes a variable and asks you for the name while a program is running. Doesn't work in Presentation mode.
All you have to do is type this in the operators section of ScriptableScratchMorph--> block specs--> blockSpecs:

('make a variable' #- #addGlobalVariable)

Draw New Costume- Opens up a paint editor for you to draw a new costume while the program is running.
All you have to do is type this in the looks section of ScratchSpriteMorph--> block specs--> blockSpecs:

('draw new costume' #- #drawNewCostume)

this is fun, exposing LS97's ideas XD (jk)

EDIT: I can't seem to make a "clone" block work, can anyone help?

Last edited by randalpik (2010-04-20 12:57:23)


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

Offline

 

#68 2010-04-20 13:04:54

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

Re: Cool custom blocks in Scratch

randalpik wrote:

EDIT: I can't seem to make a "clone" block work, can anyone help?

it's simple!
add this code:

Code:

cloneAndSend: t1 
    | t2 t3 |
    (t2 _ self ownerThatIsA: ScratchFrameMorph) ifNil: [^ self].
    t3 _ self fullCopy.
    t3 objName: objName , ' clone'.
    t3 isClone: true.
    t3 blocksBin
        allMorphsDo: [:t4 | (t4 isKindOf: BlockMorph)
                ifTrue: [t4 stop]].
    t2 workPane addMorph: t3.
    t3 eventReceived: (ScratchEvent new name: t1 asString argument: 0)

i'm not sure though  hmm

Offline

 

#69 2010-04-20 13:17:30

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

Re: Cool custom blocks in Scratch

LS97 wrote:

randalpik wrote:

EDIT: I can't seem to make a "clone" block work, can anyone help?

it's simple!
add this code:

Code:

cloneAndSend: t1 
    | t2 t3 |
    (t2 _ self ownerThatIsA: ScratchFrameMorph) ifNil: [^ self].
    t3 _ self fullCopy.
    t3 objName: objName , ' clone'.
    t3 isClone: true.
    t3 blocksBin
        allMorphsDo: [:t4 | (t4 isKindOf: BlockMorph)
                ifTrue: [t4 stop]].
    t2 workPane addMorph: t3.
    t3 eventReceived: (ScratchEvent new name: t1 asString argument: 0)

i'm not sure though  hmm

That's already in ScratchSpriteMorph. Besides, it says "incorrect number of arguments."  hmm


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

Offline

 

#70 2010-04-20 13:40:04

arthurz
Scratcher
Registered: 2010-02-03
Posts: 47

Re: Cool custom blocks in Scratch

hmm dosent work me when i get on to scriptablescratchmorph bit it comes up with  intilization, accessing, look ops, sound ops, sensing ops, list ops, string ops, motor ops, other ops, variables, scripts, blocks and a whole loadf of other stuff


Sine wave engine, check it out.
http://www.scratch.mit.edu/projects/arthurz/2816216

Offline

 

#71 2010-04-20 13:44:15

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

Re: Cool custom blocks in Scratch

Cloning blocks:
(yay, I made these)
Somewhat simplified because you don't have to send it an event, like Panther.

cloneMe
    | frame stage clone |
    (frame _ self ownerThatIsA: ScratchFrameMorph) ifNil: [(frame _ self ownerThatIsA: OffscreenWorldMorph) ifNil: [^ self] ifNotNil: [frame _ frame frame]].
    stage _ frame workPane.
    clone _ self fullCopy.
    clone objName: (self objName), ' clone'.
    stage addMorphFront: clone.

If you want to send it a broadcast message, add the line

clone eventReceived: 'Created'.

to the end and if the sprite has a 'when I receive [Created]' that will start (in the clone) when it is cloned.
It might not work, I did that off of memory, not copy-paste. (This isn't my computer)

Last edited by nXIII (2010-04-20 13:45:26)


nXIII

Offline

 

#72 2010-04-20 13:56:55

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Cool custom blocks in Scratch

nXIII wrote:

Cloning blocks:
(yay, I made these)
Somewhat simplified because you don't have to send it an event, like Panther.

cloneMe
    | frame stage clone |
    (frame _ self ownerThatIsA: ScratchFrameMorph) ifNil: [(frame _ self ownerThatIsA: OffscreenWorldMorph) ifNil: [^ self] ifNotNil: [frame _ frame frame]].
    stage _ frame workPane.
    clone _ self fullCopy.
    clone objName: (self objName), ' clone'.
    stage addMorphFront: clone.

If you want to send it a broadcast message, add the line

clone eventReceived: 'Created'.

to the end and if the sprite has a 'when I receive [Created]' that will start (in the clone) when it is cloned.
It might not work, I did that off of memory, not copy-paste. (This isn't my computer)

That means it clones in Presentation mode doesn't it?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#73 2010-04-20 14:17:30

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

Re: Cool custom blocks in Scratch

nXIII wrote:

Cloning blocks:
(yay, I made these)
Somewhat simplified because you don't have to send it an event, like Panther.

cloneMe
    | frame stage clone |
    (frame _ self ownerThatIsA: ScratchFrameMorph) ifNil: [(frame _ self ownerThatIsA: OffscreenWorldMorph) ifNil: [^ self] ifNotNil: [frame _ frame frame]].
    stage _ frame workPane.
    clone _ self fullCopy.
    clone objName: (self objName), ' clone'.
    stage addMorphFront: clone.

If you want to send it a broadcast message, add the line

clone eventReceived: 'Created'.

to the end and if the sprite has a 'when I receive [Created]' that will start (in the clone) when it is cloned.
It might not work, I did that off of memory, not copy-paste. (This isn't my computer)

Nope, doesn't work. gives me an error message about the incorrect number of arguments or something...


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

Offline

 

#74 2010-04-20 19:22:17

rocket101
Scratcher
Registered: 2009-08-21
Posts: 500+

Re: Cool custom blocks in Scratch

Nice guide, LS97!

Offline

 

#75 2010-04-21 10:59:31

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

Re: Cool custom blocks in Scratch

rocket101 wrote:

Nice guide, LS97!

thanks rocket101! i'm glad you like it and enjoy your new blocks.

Offline

 

Board footer