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

#1 2011-05-16 15:35:51

goodtime41
New Scratcher
Registered: 2011-04-11
Posts: 8

How do I add this block to scratch?

I read the post by billyedward, but I still cant get it to work. I want to add a block that says "if touching {object} bounce"
This is the code, i got it from the block library but I have no idea how or where to add it.
Blockspec:
         ('if touching %m bounce' #- #bounceOffSprite:)
code:
     bounceOffSprite: aName
    | sprite oldDir |
    sprite _ self coerceSpriteArg: aName.
    (self touching: sprite)
        ifFalse: [^ self].
    oldDir _ self heading.
    self pointTowards: sprite.
    self turnRight: self heading - oldDir + 180.
    [self touching: sprite]
        whileTrue: [self forward: 1]

Offline

 

#2 2011-05-16 15:43:36

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: How do I add this block to scratch?

Assuming you know how to get into the browser and navigate, the place is: for the blockspecs: Scratch_Objects/ScratchSpriteMorph/block specs/blockSpecs then click the class button for the code once following the place above, click the instance button.


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#3 2011-05-17 15:42:12

goodtime41
New Scratcher
Registered: 2011-04-11
Posts: 8

Re: How do I add this block to scratch?

I figured out where to insert the blockspec, but I have no clue where to insert the code. Please be detailed.
Blockspec:
         ('if touching %m bounce' #- #bounceOffSprite:)
code:
     bounceOffSprite: aName
    | sprite oldDir |
    sprite _ self coerceSpriteArg: aName.
    (self touching: sprite)
        ifFalse: [^ self].
    oldDir _ self heading.
    self pointTowards: sprite.
    self turnRight: self heading - oldDir + 180.
    [self touching: sprite]
        whileTrue: [self forward: 1]

Offline

 

#4 2011-05-17 15:45:26

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

Re: How do I add this block to scratch?

Stop spamming this question. There are now 3 topics.
1
2
3


You can now reach me on Twitter @johnnydean1_

Offline

 

#5 2011-05-17 15:49:57

goodtime41
New Scratcher
Registered: 2011-04-11
Posts: 8

Re: How do I add this block to scratch?

I figured out where to add the blockspec, but not the code

Offline

 

#6 2011-05-17 15:58:54

goodtime41
New Scratcher
Registered: 2011-04-11
Posts: 8

Re: How do I add this block to scratch?

sorry. I didn't know I could reply to my own posts untill just now.

Offline

 

#7 2011-05-20 12:39:59

williambl
Scratcher
Registered: 2011-04-08
Posts: 100+

Re: How do I add this block to scratch?

OK. so... Scratch-objects --> ScriptableSpriteMorph --> instance --> motion ops --> and paste the code.


http://internetometer.com/imagesmall/34650.png
http://www.danasoft.com/sig/Epicnesssign.jpg

Offline

 

#8 2011-05-22 05:41:07

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: How do I add this block to scratch?

The code is at: Scratch-Objects > ScriptableSpriteMorph (or the ones that have "Scriptable" in their names) > Instance > [Category] Ops > Enter the code (Don't listen to the capitalization).

Offline

 

Board footer