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

#1 2012-03-13 14:07:52

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Adding custom blocks

So... I've managed to make a custom block appear in the list of blocks, and I can insert it into a script, but I have one problem; every time the script is run, it becomes obsolete. This is because I haven't actually inserted the code anywhere. I've added the

Code:

('distance to x %n y %n' #r #dist:and:)

bit (which I think is called the blockspec), but nowhere did it even ask me for the

Code:

dist: t1 and: t2 
    ^ (self xpos - t1 * (self xpos - t1) + (self ypos - t2 * (self ypos - t2))) abs sqrt

bit.
Where do I insert the code?


Why

Offline

 

#2 2012-03-13 14:42:59

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

Re: Adding custom blocks

Yes, that's the blockspec.
Click down onto instance. Remember where class was? There.
Find the proper ops (looks like sensing ops). It should have some example text down there. Or, click on a method in the farthest right pane, delete all that (it won't really be deleted, don't worry), and paste in your new method (Alt+V).

Offline

 

#3 2012-03-13 14:49:00

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Adding custom blocks

Thanks, I'll try that.

I'm pretty sure I'll end up completely wrecking Scratch though xD


Why

Offline

 

#4 2012-03-13 14:54:22

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Adding custom blocks

Wait, I can't find proper ops.

I've gone to "Scratch-Objects>ScratchSpriteMorph", but there's no "proper ops". Or am I looking in the wrong place?


Why

Offline

 

#5 2012-03-13 15:23:19

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

Re: Adding custom blocks

It's not called "proper ops", I said you were probably looking for "sensing ops".  tongue

Offline

 

#6 2012-03-13 15:46:09

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Adding custom blocks

Oh, lol.

Anyway, before I go any further, is this right?
http://i41.tinypic.com/nna61c.png
And then where do I paste the code?


Why

Offline

 

#7 2012-03-13 16:03:27

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Adding custom blocks

Yes I have it  big_smile

Thanks sci.


Why

Offline

 

#8 2012-03-13 16:10:18

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

Re: Adding custom blocks

Yep, that was right.  smile
Glad to help a new modder, even though I've mostly stopped with that.

Offline

 

#9 2012-03-16 14:48:28

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Adding custom blocks

Reopened by request.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#10 2012-03-16 14:57:27

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Adding custom blocks

Thanks Paddle.

Okay... Do control blocks go in ScratchSpriteMorph or ScriptableScratchMorph? I've put a control block in the block specs of ScratchSpriteMorph but when I click on instance there's no "Control ops", so I don't know where to place the code for it...


Why

Offline

 

#11 2012-03-16 15:12:48

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: Adding custom blocks

Y

RedRocker227 wrote:

Thanks Paddle.

Okay... Do control blocks go in ScratchSpriteMorph or ScriptableScratchMorph? I've put a control block in the block specs of ScratchSpriteMorph but when I click on instance there's no "Control ops", so I don't know where to place the code for it...

Just go to other ops.  smile


Get ready for domination of:  tongue

Offline

 

#12 2012-03-16 15:39:02

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Adding custom blocks

I'm presuming you mean in ScriptableScratchMorph then, since there's no other ops in ScratchSpriteMorph.

Anyway... I've added the show/hide cursor blocks to the Control block specs in ScriptableScratchMorph, but I can't find the place the add the code. It doesn't come up in other ops :S


Why

Offline

 

#13 2012-03-16 16:08:11

danwoodski
Scratcher
Registered: 2009-12-23
Posts: 100+

Re: Adding custom blocks

RedRocker227 wrote:

Thanks Paddle.

Okay... Do control blocks go in ScratchSpriteMorph or ScriptableScratchMorph? I've put a control block in the block specs of ScratchSpriteMorph but when I click on instance there's no "Control ops", so I don't know where to place the code for it...

I think that it's usually put in ScriptableScratchMorph in 'other ops'.
EDIT: oops-didn't see the 2nd page  tongue

Last edited by danwoodski (2012-03-16 16:11:09)


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://dl.dropbox.com/u/12506914/Pics/p2e-2.png&link2=http://dl.dropbox.com/u/12506914/Pics/ms.png&link3=http://dl.dropbox.com/u/12506914/Pics/block%20lib.png
Starting to move on to other languages, but I'll still be around from time to time  smile

Offline

 

#14 2012-03-16 16:48:44

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Adding custom blocks

Wait I have it now.

Requesting to be closed again  tongue


Why

Offline

 

Board footer