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

#951 2010-08-26 10:28:25

zorket
Scratcher
Registered: 2010-05-25
Posts: 500+

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!

I want the blockspec! And where exactly do I put the code? It just doesn't work for me!


Marzipan11 must learn to not spoil

Offline

 

#952 2010-08-26 10:32:18

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

Re: Cool custom blocks in Scratch

Blockspec:
Source Code
('link to %s'          -     linkTo:)

NonSource
('link to %s' #- #linkTo:)

Code:
linkTo: url
     Cursor wait showWhile: [ScratchPlugin primOpenURL: url]

Last edited by bbbeb (2010-08-26 10:33:07)


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

Offline

 

#953 2010-08-26 10:33:23

kinker
Scratcher
Registered: 2010-08-01
Posts: 100+

Re: Cool custom blocks in Scratch

The shuffle block.

Follow this path,Scratch-Objects-->class ScriptableScratchMorph-->block specs-->block specs
Block spec under the operators:

Code:

('%s shuffled' #r #shuffle: 'world')

code that makes the block work in string ops:

Code:

shuffle: t1 
    ^ t1 shuffled

And there u have it!


Put in the weirdness: http://i54.tinypic.com/zl6fph.pnghttp://img821.imageshack.us/i/gobanim2.gif/kinker style! [url]http://internetometer.com/image/16724.png[/url]♬♫ 92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature. ♫♪

Offline

 

#954 2010-08-26 15:05:44

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

Re: Cool custom blocks in Scratch

I was trying to make the showing block (I haven't made any blocks yet) and I right mouse clicked and it didn't ask me to save, just some circular buttons appeared around the browser!


http://i49.tinypic.com/oiwvh5.jpg

Offline

 

#955 2010-08-26 15:27:35

jackrulez
Scratcher
Registered: 2009-08-01
Posts: 1000+

Re: Cool custom blocks in Scratch

Dominic1 wrote:

I was trying to make the showing block (I haven't made any blocks yet) and I right mouse clicked and it didn't ask me to save, just some circular buttons appeared around the browser!

Alt-click then.


Yawn, another boring text signature. I should really make something better.

Offline

 

#956 2010-08-26 15:30:27

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

Re: Cool custom blocks in Scratch

How to make a password dialog:

Step 1:

Go to Scratch-UI-Dialogs > StringDialog > initialization.

Step 2:

Down in the bottom section of the browser, type "isPassword: t1". Accept, then replace "^ self" with "typeinMorph passwordMode: t1". Accept.

Step 3:

Click class, then instance creation > askWithCancel:initialAnswer

Step 4:

To the end of the bold bit, type "password: t4", then, after "initialAnswer: t2", replace the "." with a ";" and type "isPassword: t4.". Accept.

Step 5:

Click ask:, and, at the end of the bold bit, type "password: t2", then type the same right at the end. Accept.

YOU'RE DONE!!!
Wherever you want to use your password dialog, just type "StringDialog ask: 'message' password: true"!

Last edited by TheSuccessor (2010-08-26 15:31:05)


/* No comment */

Offline

 

#957 2010-08-26 15:33:48

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

Re: Cool custom blocks in Scratch

jackrulez wrote:

Dominic1 wrote:

I was trying to make the showing block (I haven't made any blocks yet) and I right mouse clicked and it didn't ask me to save, just some circular buttons appeared around the browser!

Alt-click then.

I tried that. Ctrl-click is what worked. Thanks, you gave me the idea  smile


http://i49.tinypic.com/oiwvh5.jpg

Offline

 

#958 2010-08-26 15:51:04

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

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.

I made the block but it didn't work. It always reported Error!


http://i49.tinypic.com/oiwvh5.jpg

Offline

 

#959 2010-08-26 15:54:31

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

Re: Cool custom blocks in Scratch

And the hide block doesn't work anymore


http://i49.tinypic.com/oiwvh5.jpg

Offline

 

#960 2010-08-26 17:06:10

zorket
Scratcher
Registered: 2010-05-25
Posts: 500+

Re: Cool custom blocks in Scratch

WHY won't you include blockspecs? NONE of the blocks are working!!!


Marzipan11 must learn to not spoil

Offline

 

#961 2010-08-26 19:31:09

kinker
Scratcher
Registered: 2010-08-01
Posts: 100+

Re: Cool custom blocks in Scratch

Rewind Block
-------------------------------------------------------------------
Scratch-Objects--->Class ScriptableScratchMorph--->block specs-->block specs

Block spec under the sound category

Code:

('rewind sound %S' #- #rewindSound:)

Sound Ops,

Code:

rewindSound: t1 
    | t2 |
    t2 _ self soundNamed: t1 ifAbsent: [^ self].
    t2 rewindSound

And there you have it!


Put in the weirdness: http://i54.tinypic.com/zl6fph.pnghttp://img821.imageshack.us/i/gobanim2.gif/kinker style! [url]http://internetometer.com/image/16724.png[/url]♬♫ 92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature. ♫♪

Offline

 

#962 2010-08-26 19:52:06

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

Re: Cool custom blocks in Scratch

LS97 wrote:

The 'Get time/date' block
http://www.freeimagehosting.net/uploads/209a5b329a.gif
Here we go!
The get time/date block reports the time, date, hour, etc. without the user having to insert it manually.

Copy this line of code into a space between two blocks in the 'control' section of blockSpecs in ScriptableScratchMorph.

Code:

 ('get %s' #r #getTime: 'date')

Then go to the instance section, then to 'other ops' and replace the code of broadcast: with the following

Code:

getTime: t1 
    t1 = 'date' ifTrue: [^ Date today].
    t1 = 'short date' ifTrue: [^ Date today printFormat: #(1 2 3 $- 2 2 )].
    t1 = 'time' ifTrue: [^ Time now].
    t1 = 'seconds' ifTrue: [^ Time now seconds].
    t1 = 'minutes' ifTrue: [^ Time now minutes].
    t1 = 'hours' ifTrue: [^ Time now hours].
    t1 = 'day' ifTrue: [^ Date today weekday].
    t1 = 'help' ifTrue: [^ 'type date, short date, time, seconds, minutes, day, hours'].
    ^ 'Error!'

then right-click and click accept. type your initials and you're ready to use the new block!

NOTE:
There's a second, more advanced version of the block, with a drop-down menu instead of a string inserter, but it involves extra coding. If you are willing to take the challenge, post and i'll edit this tutorial for you

I'd like the drop down menu version


http://i49.tinypic.com/oiwvh5.jpg

Offline

 

#963 2010-08-27 08:51:59

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

Re: Cool custom blocks in Scratch

If anyone thinks that it sucks that you can't make blocks like these in BYOB, I think you actually CAN!!!!!!!

Right mouse click on a block and click edit elements. It's sort of like the squeak editor!! I'm going to try to make the link to block in BYOB!


http://i49.tinypic.com/oiwvh5.jpg

Offline

 

#964 2010-08-27 11:20:05

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

Re: Cool custom blocks in Scratch

Dominic1 wrote:

If anyone thinks that it sucks that you can't make blocks like these in BYOB, I think you actually CAN!!!!!!!

Right mouse click on a block and click edit elements. It's sort of like the squeak editor!! I'm going to try to make the link to block in BYOB!

yeah, you can. but it takes a lot because you need to go look for rach individual method in each and every individual class. and i don't always remember the Categories of the classes...  tongue

Offline

 

#965 2010-08-27 12:36:44

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

Re: Cool custom blocks in Scratch

LS97 wrote:

Dominic1 wrote:

If anyone thinks that it sucks that you can't make blocks like these in BYOB, I think you actually CAN!!!!!!!

Right mouse click on a block and click edit elements. It's sort of like the squeak editor!! I'm going to try to make the link to block in BYOB!

yeah, you can. but it takes a lot because you need to go look for rach individual method in each and every individual class. and i don't always remember the Categories of the classes...  tongue

Actually no, just type the lines of text in the "primitive" block and if it comes up with an error message, retype the lines of code there!!!!

I made the link block and the get block.


http://i49.tinypic.com/oiwvh5.jpg

Offline

 

#966 2010-08-27 13:48:33

kinker
Scratcher
Registered: 2010-08-01
Posts: 100+

Re: Cool custom blocks in Scratch

LS97 wrote:

johnnydean1 wrote:

Could you make me a <sprite _ touching sprite_> block

I'll try and see what i can do. Check back in a few mins, i might have it up!
EDIT: i got the block. here's the code:

Code:

sprite: t1 touching: t2 
    | t3 |
    t3 _ t1 bounds intersect: t2 bounds.
    (t3 width > 0 and: [t3 height > 0])
        ifTrue: [^ true].
    ^ false

i'm so proud of myself  smile

What the block spec?


Put in the weirdness: http://i54.tinypic.com/zl6fph.pnghttp://img821.imageshack.us/i/gobanim2.gif/kinker style! [url]http://internetometer.com/image/16724.png[/url]♬♫ 92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature. ♫♪

Offline

 

#967 2010-08-27 17:05:58

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

Re: Cool custom blocks in Scratch

.....
('Sprite %m is touching sprite %m'  #b  #sprite:touching:)


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

Offline

 

#968 2010-08-27 17:15:09

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Cool custom blocks in Scratch

Is it possible to make custom hat blocks? I've found the control blockspecs, but no matter what block type I mark it as (with the hashtag + letter) just gives me the appearance of the normal hat with that identifier.  So if I put the tag for "when greenflag clicked", I just get a block that looks identical to it no matter what the text in quotes.

Last edited by Harakou (2010-08-27 17:18:02)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#969 2010-08-27 17:33:07

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

Re: Cool custom blocks in Scratch

It takes a lot to make one.
Look at 2 things:
the hats
and the execution engine.


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

Offline

 

#970 2010-08-27 17:47:17

kinker
Scratcher
Registered: 2010-08-01
Posts: 100+

Re: Cool custom blocks in Scratch

The when <> is true block.
____________________________________
block spec:

Code:

('when %W is true' #W #-)

no code.
Tada! get ready to use ur new block.


Put in the weirdness: http://i54.tinypic.com/zl6fph.pnghttp://img821.imageshack.us/i/gobanim2.gif/kinker style! [url]http://internetometer.com/image/16724.png[/url]♬♫ 92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature. ♫♪

Offline

 

#971 2010-08-28 04:50:54

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

Re: Cool custom blocks in Scratch

kinker wrote:

The when <> is true block.
____________________________________
block spec:

Code:

('when %W is true' #W #-)

no code.
Tada! get ready to use ur new block.

tisk tisk. you think it's so easy? it's not.
look at this post

Offline

 

#972 2010-08-28 04:53:01

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

Re: Cool custom blocks in Scratch

Harakou wrote:

Is it possible to make custom hat blocks? I've found the control blockspecs, but no matter what block type I mark it as (with the hashtag + letter) just gives me the appearance of the normal hat with that identifier.  So if I put the tag for "when greenflag clicked", I just get a block that looks identical to it no matter what the text in quotes.

and no you can't do it like that because of the blockFromSpec method which automatically adds the default text to the hat blocks. so if you want to make custom block type (for example a byte reporter) you'll have to look into
ScriptableScratchMorph > blocks > blockFromSpec:color:
and add your own letter.

that's not all done obviously...

Offline

 

#973 2010-08-28 14:10:45

Dominic1
Scratcher
Registered: 2009-07-30
Posts: 89

Re: Cool custom blocks in Scratch

Can you make a block that opens the paint editor? I've been trying, but I can't get it to work.


http://i49.tinypic.com/oiwvh5.jpg

Offline

 

#974 2010-08-29 05:45:02

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

Re: Cool custom blocks in Scratch

Dominic1 wrote:

Can you make a block that opens the paint editor? I've been trying, but I can't get it to work.

if you want it to open the editor to create a new costume it's pretty easy.
i had a look at the source code and found
('paint new' - drawNewCostume)
it's as simple as that.
not sure if it works though

Offline

 

#975 2010-08-29 09:42:58

Grin1
Scratcher
Registered: 2010-06-10
Posts: 31

Re: Cool custom blocks in Scratch

LS97 wrote:

The 'Get time/date' block
http://www.freeimagehosting.net/uploads/209a5b329a.gif
Here we go!
The get time/date block reports the time, date, hour, etc. without the user having to insert it manually.

Copy this line of code into a space between two blocks in the 'control' section of blockSpecs in ScriptableScratchMorph.

Code:

 ('get %s' #r #getTime: 'date')

Then go to the instance section, then to 'other ops' and replace the code of broadcast: with the following

Code:

getTime: t1 
    t1 = 'date' ifTrue: [^ Date today].
    t1 = 'short date' ifTrue: [^ Date today printFormat: #(1 2 3 $- 2 2 )].
    t1 = 'time' ifTrue: [^ Time now].
    t1 = 'seconds' ifTrue: [^ Time now seconds].
    t1 = 'minutes' ifTrue: [^ Time now minutes].
    t1 = 'hours' ifTrue: [^ Time now hours].
    t1 = 'day' ifTrue: [^ Date today weekday].
    t1 = 'help' ifTrue: [^ 'type date, short date, time, seconds, minutes, day, hours'].
    ^ 'Error!'

then right-click and click accept. type your initials and you're ready to use the new block!

NOTE:
There's a second, more advanced version of the block, with a drop-down menu instead of a string inserter, but it involves extra coding. If you are willing to take the challenge, post and i'll edit this tutorial for you

I WANT A drop down list.


http://scratch.mit.edu/projects/Grin1/1870603
http://scratch.mit.edu/static/projects/Grin1/1870603_med.png

Offline

 

Board footer