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

#201 2010-05-05 14:50:40

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

Re: Cool custom blocks in Scratch

OOPS. :-( Something went wrong. WHAT shall i do it said: cant locate .scorses and .changes files  sad  i think i'll have to reinstall scratch  sad   sad


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

Offline

 

#202 2010-05-05 22:45:01

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

Re: Cool custom blocks in Scratch

comp500 wrote:

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

make sure its not in the 'scriptable scratch morph'  smile


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

Offline

 

#203 2010-05-06 09:02:03

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

Re: Cool custom blocks in Scratch

Joeman592 wrote:

comp500 wrote:

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

make sure its not in the 'scriptable scratch morph'  smile

It works i restarted scratch  smile


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

Offline

 

#204 2010-05-06 09:04:40

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

Re: Cool custom blocks in Scratch

comp500 wrote:

Joeman592 wrote:

comp500 wrote:


Doesn't work  sad

make sure its not in the 'scriptable scratch morph'  smile

It works i restarted scratch  smile

Huh its there but it always says false


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

Offline

 

#205 2010-05-06 09:06:49

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

Re: Cool custom blocks in Scratch

comp500 wrote:

comp500 wrote:

Joeman592 wrote:


make sure its not in the 'scriptable scratch morph'  smile

It works i restarted scratch  smile

Huh its there but it always says false

Only left-click works  sad


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

Offline

 

#206 2010-05-06 09:21:41

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

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!

This one works!!! It is soo cool


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

Offline

 

#207 2010-05-06 10:11:06

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

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!

Where shall i put this code? i put the block spec in sensing and i used your spec.


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

Offline

 

#208 2010-05-06 10:24:29

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

Re: Cool custom blocks in Scratch

<forever>
I like custom blocks
<end>


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

Offline

 

#209 2010-05-06 10:53:24

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

Re: Cool custom blocks in Scratch

comp500 wrote:

comp500 wrote:

comp500 wrote:


It works i restarted scratch  smile

Huh its there but it always says false

Only left-click works  sad

no, put the block into a 'say []' and do a forever loop. then try pressing the different mouse buttons (and change text in it (left, right, middle) to check all three.

Offline

 

#210 2010-05-07 11:32:11

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

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!

What is the block spec? is it something like this:

Code:

('open %s' #s #gotoopen)

smile
Comp500


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

Offline

 

#211 2010-05-07 11:33:53

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

Re: Cool custom blocks in Scratch

LS97 wrote:

comp500 wrote:

comp500 wrote:


Huh its there but it always says false

Only left-click works  sad

no, put the block into a 'say []' and do a forever loop. then try pressing the different mouse buttons (and change text in it (left, right, middle) to check all three.

Ok.  smile


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

Offline

 

#212 2010-05-07 11:36:49

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

Re: Cool custom blocks in Scratch

comp500 wrote:

LS97 wrote:

comp500 wrote:


Only left-click works  sad

no, put the block into a 'say []' and do a forever loop. then try pressing the different mouse buttons (and change text in it (left, right, middle) to check all three.

Ok.  smile

It works i have to put it full screen  smile  Yipee i can now work on my OS!!


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

Offline

 

#213 2010-05-07 12:05:12

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

Re: Cool custom blocks in Scratch

comp500 wrote:

comp500 wrote:

LS97 wrote:


no, put the block into a 'say []' and do a forever loop. then try pressing the different mouse buttons (and change text in it (left, right, middle) to check all three.

Ok.  smile

It works i have to put it full screen  smile  Yipee i can now work on my OS!!

These blocks don't work online, or when downloaded by other people.


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

Offline

 

#214 2010-05-07 12:47:59

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

Re: Cool custom blocks in Scratch

randalpik wrote:

These blocks don't work online, or when downloaded by other people.

unless you include the image in a ZIP folder and upload it to a site  smile

Offline

 

#215 2010-05-07 12:50:01

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

Re: Cool custom blocks in Scratch

comp500 wrote:

What is the block spec? is it something like this:

Code:

('open %s' #s #gotoopen)

Comp500

yes, that's pretty close. you can have this:

Code:

 ('link to %s' #- #openLink: 'http://scratch.mit.edu')

but obviously the title of the actual block code has to be openLink: t1

Offline

 

#216 2010-05-07 12:52:03

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

Re: Cool custom blocks in Scratch

Zorbak42 wrote:

Joeman592 wrote:

Zorbak42 wrote:


I can give you code for change costume # by (). Put

Code:

changeCostumeIndexBy: t1 
    self costumeIndex: self costumeIndex + t1

in looks ops of ScriptableScratchMorph instance,

Code:

('change costume by %n' #- #changeCostumeIndexBy: 1)

in SpriteMorph blockSpecs, and

Code:

('change background by %n' #- #changeBackgroundIndexBy: 1)

in StageMorph blockSpecs. Hope it helps!  smile

THANK YOU SOOOOOOOO MUCH!

You're welcome.  smile  I've heard the I receive block is impossible to make, I'm not sure if this is true, but I don't think anyone has it.  sad  I'll try to make a bounce block now... ...Almost got it. An error message appeared saying t1 and t2 are undefined or something.  sad 

Code:

bounce
    | t1 t2 t3 t4 |
    t3 _ self rotationDegrees degreesToRadians cos.
    t4 _ self rotationDegrees degreesToRadians sin negated.
    t1 left < t2 left ifTrue: [t3 _ t3 abs].
    t1 right > t2 right ifTrue: [t3 _ t3 abs negated].
    t1 top < t2 top ifTrue: [t4 _ t4 abs negated].
    t1 bottom > t2 bottom ifTrue: [t4 _ t4 abs].
    self rotationDegrees: (t4 negated asFloat arcTan: t3) radiansToDegrees.
    self position: self position + (t1 amountToTranslateWithin: t2)

If you find out what's wrong, please let me know. Bounce, if touching, if I can figure out what's wrong with bounce, I might be able to do that. Think nothing, you can just use the say nothing, it will stop what it's thinking too.

Code:

('say nothing' #- #sayNothing)

smile

What is the spec? I'll try to work it out if you tell me.Anyway the name is defined wrong so i'll tell you if you tell me the spec. smile


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

Offline

 

#217 2010-05-07 12:53:07

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

Re: Cool custom blocks in Scratch

Zorbak42 wrote:

Joeman592 wrote:

Zorbak42 wrote:


I can give you code for change costume # by (). Put

Code:

changeCostumeIndexBy: t1 
    self costumeIndex: self costumeIndex + t1

in looks ops of ScriptableScratchMorph instance,

Code:

('change costume by %n' #- #changeCostumeIndexBy: 1)

in SpriteMorph blockSpecs, and

Code:

('change background by %n' #- #changeBackgroundIndexBy: 1)

in StageMorph blockSpecs. Hope it helps!  smile

THANK YOU SOOOOOOOO MUCH!

You're welcome.  smile  I've heard the I receive block is impossible to make, I'm not sure if this is true, but I don't think anyone has it.  sad  I'll try to make a bounce block now... ...Almost got it. An error message appeared saying t1 and t2 are undefined or something.  sad 

Code:

bounce
    | t1 t2 t3 t4 |
    t3 _ self rotationDegrees degreesToRadians cos.
    t4 _ self rotationDegrees degreesToRadians sin negated.
    t1 left < t2 left ifTrue: [t3 _ t3 abs].
    t1 right > t2 right ifTrue: [t3 _ t3 abs negated].
    t1 top < t2 top ifTrue: [t4 _ t4 abs negated].
    t1 bottom > t2 bottom ifTrue: [t4 _ t4 abs].
    self rotationDegrees: (t4 negated asFloat arcTan: t3) radiansToDegrees.
    self position: self position + (t1 amountToTranslateWithin: t2)

If you find out what's wrong, please let me know. Bounce, if touching, if I can figure out what's wrong with bounce, I might be able to do that. Think nothing, you can just use the say nothing, it will stop what it's thinking too.

Code:

('say nothing' #- #sayNothing)

smile

What is the spec? I'll try to work it out if you tell me.Anyway the name is defined wrong so i'll tell you if you tell me the spec. smile


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

Offline

 

#218 2010-05-07 13:37:16

electrified123
Scratcher
Registered: 2009-11-22
Posts: 100+

Re: Cool custom blocks in Scratch

('pen down' #r #penDown) reports if pen is down

Last edited by electrified123 (2010-05-07 13:45:23)


http://i47.tinypic.com/5nrzmp.jpg check out my stuff ~ If You Really Thought i would think what you thought, than you must think i think what you thought i would think at the time you thought i was thinking what you thought

Offline

 

#219 2010-05-07 13:51:05

electrified123
Scratcher
Registered: 2009-11-22
Posts: 100+

Re: Cool custom blocks in Scratch

('pen color' #r #penColor) pen color reporter ('pen size' #r #penSize) pen size reporter


http://i47.tinypic.com/5nrzmp.jpg check out my stuff ~ If You Really Thought i would think what you thought, than you must think i think what you thought i would think at the time you thought i was thinking what you thought

Offline

 

#220 2010-05-07 14:14:47

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

Re: Cool custom blocks in Scratch

I'm going to try to compile all these specs and code into a text file...  smile


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

Offline

 

#221 2010-05-07 15:01:33

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

Re: Cool custom blocks in Scratch

Can anybody do (erasor down) etc. and (permanent marker down) etc. ?  hmm


/* No comment */

Offline

 

#222 2010-05-07 15:16:37

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

Re: Cool custom blocks in Scratch

(If on edge, teleport) code:

Code:

| t1 t2 t3 t4 |
t3 _ self referencePosition x.
t4 _ self referencePosition y.
t3 abs = 240
     ifTrue:
          [t1 _ -1 * (t3 - (t3 / 240)).
           t2 _ t4]
     ifFalse:
          [t1 _ t3.
           t2 _ t4].
t4 abs = 180 ifTrue: [t2 _ -1 * (t4 - (t4 / 180))].
self referencePosition: t1 @ t2

Works, but a bit crude. Can anyone improve it?  smile

Last edited by TheSuccessor (2010-05-07 15:17:46)


/* No comment */

Offline

 

#223 2010-05-07 17:02:59

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

Re: Cool custom blocks in Scratch

TheSuccessor wrote:

Can anybody do (erasor down) etc. and (permanent marker down) etc. ?  hmm

I don't see the need for that... you can just change the pen size and color


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

Offline

 

#224 2010-05-07 17:39:38

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

Re: Cool custom blocks in Scratch

randalpik wrote:

TheSuccessor wrote:

Can anybody do (erasor down) etc. and (permanent marker down) etc. ?  hmm

I don't see the need for that... you can just change the pen size and color

no, you need a 'set pen to eraser'


nXIII

Offline

 

#225 2010-05-07 19:00:59

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

Re: Cool custom blocks in Scratch

nXIII wrote:

randalpik wrote:

TheSuccessor wrote:

Can anybody do (erasor down) etc. and (permanent marker down) etc. ?  hmm

I don't see the need for that... you can just change the pen size and color

no, you need a 'set pen to eraser'

Why don't you just have "set pen color to white"


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

Offline

 

Board footer