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

#1376 2011-01-13 22:22:47

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: Cool custom blocks in Scratch

Make a block that changes pitch with a mic so that you can have a sprite move up and down according to your pitch.PLEASE?


I am currently http://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=imagehttp://blocks.scratchr.org/API.php?user=GP1&action=onlineStatus&type=text and I finally got over 1000 posts.

Offline

 

#1377 2011-01-14 11:17:15

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

Re: Cool custom blocks in Scratch

GP1 wrote:

Make a block that changes pitch with a mic so that you can have a sprite move up and down according to your pitch.PLEASE?

I believe there's a block for that already...

Offline

 

#1378 2011-01-14 12:12:59

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Cool custom blocks in Scratch

LS97 wrote:

GP1 wrote:

Make a block that changes pitch with a mic so that you can have a sprite move up and down according to your pitch.PLEASE?

I believe there's a block for that already...

Made by Jens as a change set (in 1.3)


You can now reach me on Twitter @johnnydean1_

Offline

 

#1379 2011-01-14 23:16:59

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

Re: Cool custom blocks in Scratch

johnnydean1 wrote:

LS97 wrote:

GP1 wrote:

Make a block that changes pitch with a mic so that you can have a sprite move up and down according to your pitch.PLEASE?

I believe there's a block for that already...

Made by Jens as a change set (in 1.3)

Smalltalk cannot read Pitch. It has been confirmed already.

It is sad.  sad


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

Offline

 

#1380 2011-01-18 15:24:47

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Cool custom blocks in Scratch

pen13 wrote:

a log off  block

if you mean log off scratch, i think it is:
spec:
('log off scratch' #- #logOff)
method (other ops):

Code:

logOff
Cursor wait showWhile: [ScratchPlugin primOpenURL: 'http://scratch.mit.edu/logout']

Offline

 

#1381 2011-01-19 20:54:14

Marioblender
Scratcher
Registered: 2010-04-04
Posts: 31

Re: Cool custom blocks in Scratch

me450 wrote:

zorket wrote:

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

im fine with extra advanced tutorial as it would produce less errors

please post

Thanks  smile  (:

I've copied his way exactly. here it is:

ok. note that this is for the source code. if you are using normal scratch replace the 'code' with 't2'
into Scratch-Blocks > CommandBlockMorph > all > uncoloredArgMorphFor:
add a line that looks like this:
$t = code ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #timeDates].
back in ScriptableScratchMorph, create a new method with this code:

timeDates
^ #('time' 'date' 'short date' 'seconds' 'minutes' 'seconds' 'hours' 'weekday')

now replace the blockSpec you created with ('get %t' r getDate: 'time')

Replace the code with:

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 = 'weekday' ifTrue: [^ Date today weekday].
^ 'Error!'

___________________________________________
I've edited the tutorial a little. LYSD didn't post the tutorial correctly.

thanks

ive edited it a bit to make it work on normal scratch

and also it says error when i use the block

thanks

the 'getDate' part in the blockspec has to be replaced with 'getTime'.

I also have two more date pieces to insert in the 'getTime code:

Code:

 
t1 = 'month' ifTrue: [^ Date today month].
t1 = 'year' ifTrue: [^ Date today year].

After you placed the code, insert this strip into the 'timeDates' code after 'weekdays':

Code:

 'month' 'year'

Now you can view month (month with year) and year alone with your 'get time/date ' block!

Last edited by Marioblender (2011-01-19 21:17:38)

Offline

 

#1382 2011-01-25 16:57:01

jcml
Scratcher
Registered: 2010-10-08
Posts: 12

Re: Cool custom blocks in Scratch

can you make me a (last brodcasted) block
PLEASE!!!


I need help for one huge a mesh game i need to no how to make a world-wide scratch program if you have any idea's just coment on one of my projects

Offline

 

#1383 2011-01-25 20:16:21

hpotter134
Scratcher
Registered: 2010-02-21
Posts: 100+

Re: Cool custom blocks in Scratch

jcml wrote:

can you make me a (last brodcasted) block
PLEASE!!!

http://img535.imageshack.us/img535/8024/lastbroadcast.gif

This block works, but for some reason, there is a separate block for each sprite. (i.e. each sprite has a checkmark next to this block, but all the values are the same. Does that make sense?)

Go to Scratch-Objects>>ScriptableScratchMorph

Add a class variable called LastMessage. To do this, find the list of class variables, and add LastMessage to it, separated from the other items with a space. This would probably make the code look like this:

Code:

Morph subclass: #ScriptableScratchMorph
    instanceVariableNames: 'objName vars lists blocksBin isClone media costume costumeChangeMSecs filterPack visibility volume tempoBPM sceneStates '
    classVariableNames: 'BlockColorDict BlockSpecDict DefaultBackgroundForm DefaultSpriteForm DoubleSize Experimental LastMessage ListBlockColor MeowSound OldMeowPrefixReversed PopSound RandomGen Recorder ScratchOrigin TimerStartMSecs '
    poolDictionaries: ''
    category: 'Scratch-Objects'

Then go to Scratch-Objects>>ScriptableScratchMorph>>accessing

Replace the text at the bottom with the following code.

Code:

lastMessage
    ^ LastMessage

Save that (Alt+S) then click accessing again. The text at the bottom should be replaced by the method template. Replace that with:

Code:

lastMessage: t1 
    LastMessage _ t1

Then go to Scratch-Objects>>ScriptableScratchMorph>>other ops>>broadcast:
Replace the text there with:

Code:

broadcast: t1 
    self broadcast: t1 withArgument: 0.
    self lastMessage: t1

Go to Scratch-Objects>>ScriptableScratchMorph>>other ops>>broadcast:withArgument:
Replace the text there with:

Code:

broadcast: t1 withArgument: t2 
    | t3 |
    (t3 _ self ownerThatIsA: ScratchStageMorph) ifNotNil: [t3 broadcastEventNamed: t1 asString with: t2].
    self lastMessage: t1

Finally, go to Scratch-Objects>>ScriptableScratchMorph>>class>>block specs>>blockSpecs

Choose where to put your block, and add the following block spec:

Code:

('last broadcast' #r #lastMessage)

If someone finds a problem in my work, or finds a better way to do it, please correct me.


http://i45.tinypic.com/fxgtvc.png

Offline

 

#1384 2011-01-26 02:10:44

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Cool custom blocks in Scratch

It works!
If you go to Scratch-Blocks>>CommandBlockMorph>>private>>canBecomeWatcher and add the text #lastMessage with the rest, it won't show on the stage.

Offline

 

#1385 2011-01-26 14:16:36

Lightning1234
Scratcher
Registered: 2010-12-02
Posts: 5

Re: Cool custom blocks in Scratch

Can someone please make me a booklean version of the "When I recieve block"? PLEASE


http://www.nodiatis.com/pub/1.jpg

Offline

 

#1386 2011-01-26 14:20:17

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

Re: Cool custom blocks in Scratch

('%e received?'  #b #seesBroadcast:)

seesBroadcast: t1
    | t2 |
    t2 _ ScratchEvent allInstances.
    t2
        reverseDo:     
            [:t3 |
            t3 name = t1 ifTrue: [^ true].
            nil].
    ^ false

Credit to rubiks_cube_guy238 and (i think) nXIII.

Last edited by bbbeb (2011-01-26 14:20:45)


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

Offline

 

#1387 2011-01-26 17:38:38

hpotter134
Scratcher
Registered: 2010-02-21
Posts: 100+

Re: Cool custom blocks in Scratch

scimonster wrote:

It works!
If you go to Scratch-Blocks>>CommandBlockMorph>>private>>canBecomeWatcher and add the text #lastMessage with the rest, it won't show on the stage.

That sort of solves the problem. You see, the problem is not that it shows on the Stage, it's that it shows as a local variable of each sprite. For example, "answer" is a global variable, and is shown on the stage once.

last broadcasted shows up on the stage separately for each sprite, but they all have the same value because you can't have local broadcasts.

like this:
http://img546.imageshack.us/img546/5166/glitchofmessage.png

Last edited by hpotter134 (2011-01-26 17:45:18)


http://i45.tinypic.com/fxgtvc.png

Offline

 

#1388 2011-01-27 02:08:53

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Cool custom blocks in Scratch

I know. I don't know where is the thing that determines if it's global or sprite specific. Probably in Scratch-UI-Watchers.

Offline

 

#1389 2011-01-27 11:52:21

Lightning1234
Scratcher
Registered: 2010-12-02
Posts: 5

Re: Cool custom blocks in Scratch

bbbeb wrote:

('%e received?'  #b #seesBroadcast:)

seesBroadcast: t1
    | t2 |
    t2 _ ScratchEvent allInstances.
    t2
        reverseDo:     
            [:t3 |
            t3 name = t1 ifTrue: [^ true].
            nil].
    ^ false

Credit to rubiks_cube_guy238 and (i think) nXIII.

This doesn't work


http://www.nodiatis.com/pub/1.jpg

Offline

 

#1390 2011-01-27 19:09:28

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

Re: Cool custom blocks in Scratch

Lightning1234 wrote:

bbbeb wrote:

('%e received?'  #b #seesBroadcast:)

seesBroadcast: t1
    | t2 |
    t2 _ ScratchEvent allInstances.
    t2
        reverseDo:     
            [:t3 |
            t3 name = t1 ifTrue: [^ true].
            nil].
    ^ false

Credit to rubiks_cube_guy238 and (i think) nXIII.

This doesn't work

Put the 1st one in the category:

Scratch-Objects -> ScriptableScratchMorph -> Classes -> Block Specs -> Blockspecs

Put the 2nd one in:

Scratch-Objects -> ScriptableScratchMorph -> Instance -> Other ops


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

Offline

 

#1391 2011-01-28 08:03:35

hpotter134
Scratcher
Registered: 2010-02-21
Posts: 100+

Re: Cool custom blocks in Scratch

scimonster wrote:

I know. I don't know where is the thing that determines if it's global or sprite specific. Probably in Scratch-UI-Watchers.

I did a bit of searching, and found this method at Scratch-Objects>>ScriptableScratchMorph>>class>>other>>isSpriteSpecificTarget:Selector:

Here's the code currently there.

Code:

isSpriteSpecificTarget: t1 selector: t2 
    | t3 |
    (t1 isKindOf: ScratchSpriteMorph)
        ifFalse: [^ false].
    t3 _ t2 asString findAnySubStr: #('answer' 'key' 'Loud' 'mouse' 'sensor' 'soundLevel' 'tempo' 'timer' ) startingAt: 1.
    ^ t3 > t2 asString size

Could someone please explain this to me? For last broadcast, it returns true, which causes my problem. I tried just writing ^false, and it worked fine, but local variables no longer had the name of the sprite before them.

I found this method through Scratch-UI-Watchers>>WatcherMorph>>initialization>>target:selector:parameter.

It would help if someone explained that to me too...I'm rather confused... hmm


http://i45.tinypic.com/fxgtvc.png

Offline

 

#1392 2011-01-29 00:27:46

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

Re: Cool custom blocks in Scratch

OMG this thread has grown so much... i have not been on it in a while, so long in fact that i forgot how to program my own blocks... guess i'll have to check up on that.

I bet i missed so many block ideas... the last time i checked there were 30 pages...


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

Offline

 

#1393 2011-01-30 04:31:37

marley2002
Scratcher
Registered: 2009-04-14
Posts: 3

Re: Cool custom blocks in Scratch

[blocks]<when[ any ]key pressed>
<key[ any ]pressed?>

I would like these blocks.
I tried making them myself but failed.
I would like mabye a tutoriol.

More blocks requested:
<change[ blur ]effect by( 25 )
<set pen color to( r: g: b: ) [/blocks]

Last edited by marley2002 (2011-01-30 04:38:34)

Offline

 

#1394 2011-01-30 05:06:51

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Cool custom blocks in Scratch

zorket wrote:

zorket wrote:

I am trying to make a [Draw square] block. Here my current code:

Code:

drawSquare
    self putPenUp.
    self referencePosition: -100 @ 100.
    self penDown.
    self referencePosition: 100 @ 100.
    self referencePosition: 100 @ -100.
    self referencePosition: -100 @ -100.
    self referencePosition: -100 @ 100.
    self putPenUp

This code doesn't seem to work. Maybe try and stretch it's activation out a little?

No, you never put pen down; it starts with PutPenUp!


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#1395 2011-01-30 05:09:30

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Cool custom blocks in Scratch

Hey! I found out how to make repeats!

I wrote:

Here's how (follow this pattern):

Code:

<selector name>
    | repeatclient |
    repeatclient _ <number of times it should repeat>
    self <selector name> + <repeatno: repeatclient>

Code:

<selector name> + <repeatno: repeatclient>
    repeatclient = 0 ifTrue: [^ self].
    <coding to be repeated>
    self <selector name> + <repeatno: repeatclient - 1>

Quoted from the block library

Last edited by Hardmath123 (2011-01-30 05:19:08)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#1396 2011-01-30 08:55:41

hpotter134
Scratcher
Registered: 2010-02-21
Posts: 100+

Re: Cool custom blocks in Scratch

hpotter134 wrote:

scimonster wrote:

I know. I don't know where is the thing that determines if it's global or sprite specific. Probably in Scratch-UI-Watchers.

I did a bit of searching, and found this method at Scratch-Objects>>ScriptableScratchMorph>>class>>other>>isSpriteSpecificTarget:Selector:

Here's the code currently there.

Code:

isSpriteSpecificTarget: t1 selector: t2 
    | t3 |
    (t1 isKindOf: ScratchSpriteMorph)
        ifFalse: [^ false].
    t3 _ t2 asString findAnySubStr: #('answer' 'key' 'Loud' 'mouse' 'sensor' 'soundLevel' 'tempo' 'timer' ) startingAt: 1.
    ^ t3 > t2 asString size

Could someone please explain this to me? For last broadcast, it returns true, which causes my problem. I tried just writing ^false, and it worked fine, but local variables no longer had the name of the sprite before them.

I did it! If you add 'Message' to the list in the above method, it is shown as a global variable!
http://img716.imageshack.us/img716/5126/fixedmessage.png


http://i45.tinypic.com/fxgtvc.png

Offline

 

#1397 2011-01-31 02:08:06

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Cool custom blocks in Scratch

I don't think you ever gave the link to the show/hide list blocks, so here it is: http://scratch.mit.edu/forums/viewtopic.php?id=32494 by nXIII

Offline

 

#1398 2011-02-07 13:56:45

muddyfish
New Scratcher
Registered: 2011-01-27
Posts: 13

Re: Cool custom blocks in Scratch

How do you make it so that it asks you things like broadcast(
                                                                                    list here...
)

Offline

 

#1399 2011-02-07 14:02:58

muddyfish
New Scratcher
Registered: 2011-01-27
Posts: 13

Re: Cool custom blocks in Scratch

muddyfish wrote:

How do you make it so that it asks you things like broadcast(
                                                                                    pigeons
                                                                                    pigeons
                                                                                    pigeons)
but with a differant list insted like (
                                                 tent
                                                 octopus
                                                 man)

Offline

 

#1400 2011-02-07 14:03:11

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Cool custom blocks in Scratch

muddyfish wrote:

How do you make it so that it asks you things like broadcast(
                                                                                    list here...
)

what do you mean?

Offline

 

Board footer