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

#801 2010-07-10 23:17:03

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Cool custom blocks in Scratch

Wait... The only problem with custom blocks is that you cannot use them in a project you plan to share. It needs some javascript code to go with it, otherwise Java won't know how to handle the new block. Great tutorial, anyway.  smile


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#802 2010-07-11 10:08:52

bendad
Scratcher
Registered: 2008-06-14
Posts: 100+

Re: Cool custom blocks in Scratch

I am using almost all of these blocks in my new mod, Peak. You (LS97) will be the first person on the contributers list.


Hi!  big_smile
Good to see you. (Even if I don't know you  wink  )

Offline

 

#803 2010-07-11 10:44:55

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

Re: Cool custom blocks in Scratch

bendad wrote:

I am using almost all of these blocks in my new mod, Peak. You (LS97) will be the first person on the contributers list.

If you wait a bit you can mod Blocks++


nXIII

Offline

 

#804 2010-07-11 13:15:12

stickdude123
Scratcher
Registered: 2010-05-31
Posts: 100+

Re: Cool custom blocks in Scratch

randalpik wrote:

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!

For people who aren't sure how to put this in the block specs, here's a good way:

Code:

 ('go to website %s' #- #getLink: 'http://scratch.mit.edu/')

The result will be a block that says "go to website [http://scratch.mit.edu/]" wherein scratch.mit.edu is what it says by default.

that code of urs almost crashed meh controlls!


http://internetometer.com/imagesmall/34259.png http://www.mediafire.com/convkey/418e/lkb7wmv2n2k73rz5g.jpg         http://blocks.scratchr.org/API.php?user=stickdude123&action=onlineStatus&type=square

Offline

 

#805 2010-07-12 11:45:18

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

Re: Cool custom blocks in Scratch

If you make a mistake when coding a custom block and when try to use block it causes an error, all of your other custom blocks (but none of the normal ones) stop working and you have to restart Scratch. It's really annoying, so can anybody tell me why it does this? Also, why is it only the other custom blocks that jam up, not the normal ones?


/* No comment */

Offline

 

#806 2010-07-12 12:55:34

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

Re: Cool custom blocks in Scratch

TheSuccessor wrote:

If you make a mistake when coding a custom block and when try to use block it causes an error, all of your other custom blocks (but none of the normal ones) stop working and you have to restart Scratch. It's really annoying, so can anybody tell me why it does this? Also, why is it only the other custom blocks that jam up, not the normal ones?

Sometimes you have to click the stop-sign to dismiss the error.


nXIII

Offline

 

#807 2010-07-12 13:03:51

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

Re: Cool custom blocks in Scratch

^ I get that in CYOB but it stops all Panther blocks!


You can now reach me on Twitter @johnnydean1_

Offline

 

#808 2010-07-13 10:30:17

timothymh
Scratcher
Registered: 2008-07-20
Posts: 10

Re: Cool custom blocks in Scratch

Could you detail how to make a block that looks like [blocks]<when[ Sprite1 ]clicked>[/blocks] but is boolean?


I am not a hippopotamus. I apologize in advance for any inconveniences this may cause.

Offline

 

#809 2010-07-13 11:31:51

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

Re: Cool custom blocks in Scratch

ill make it now!


You can now reach me on Twitter @johnnydean1_

Offline

 

#810 2010-07-13 11:52:22

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

Re: Cool custom blocks in Scratch

Name:
im clicked?

Type:
#b

Code:

clicked

|clicked other stage|
clicked_ 0.     

stage _ self ownerThatIsA: ScratchStageMorph.
other_ self containsPoint: stage adjustedCursorPoint.



other = true
ifTrue:
[
clicked_ clicked + 1.
].
other_ self mousePressed.
other = true
ifTrue:
[
clicked_ clicked + 1.
].

clicked = 2
ifTrue:
[
^ true.
]
ifFalse: [
^ false.
].

Block Spec
Source:
('im clicked?'                 b       clicked)

Normal:
('im clicked?'                #b     #clicked)

NOTE:
If used in CYOB remove the first line...


You can now reach me on Twitter @johnnydean1_

Offline

 

#811 2010-07-14 12:17:53

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

Re: Cool custom blocks in Scratch

or just

    | t1 |
    (t1 _ self ownerThatIsA: ScratchStageMorph) ifNil: [^ false].
    ^ (self containsPoint: t1 adjustedCursorPoint)
        & Sensor anyButtonPressed

Last edited by nXIII (2010-07-14 12:23:23)


nXIII

Offline

 

#812 2010-07-18 22:07:52

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

Re: Cool custom blocks in Scratch

LS97,
can you make these 2?
<talking?>
<say [] until <> > (i am far from pro at squeak!)
(edit = someone?)

Last edited by bbbeb (2010-07-18 22:09:37)


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

Offline

 

#813 2010-07-19 06:50:03

climber59
Scratcher
Registered: 2009-12-15
Posts: 100+

Re: Cool custom blocks in Scratch

For the [say () until <>] use

[say ()]
[wait until <>]


Check out my projects if you have a chance.

Offline

 

#814 2010-07-19 15:38:39

meowmeow55
Scratcher
Registered: 2008-12-24
Posts: 1000+

Re: Cool custom blocks in Scratch

climber59 wrote:

For the [say () until <>] use

[say ()]
[wait until <>]

[blocks]<say[ blah ]>
<wait until>
<say[ ]>[/blocks]
That's what it should be, you forgot the "say []" to make the sprite stop talking.


Yawn.

Offline

 

#815 2010-07-20 15:24:35

Ralphjos
Scratcher
Registered: 2009-10-10
Posts: 100+

Re: Cool custom blocks in Scratch

Thanks for this tutorial. It has helped somewhat. So far, I'm able to read and understand little, aswell as easily create the blocks that you've guided us through. I have a desire for this certain block, since it will greatly improve the game I am working on. I would like to know how to add, "Replace [thing] of [List] with [thing]". I haven't surfed through all thirty-three pages of this thread, so if I missed anything important, like you're not taking suggestions anymore, then my bad.  tongue 

Regards,
   Ralphjos

Last edited by Ralphjos (2010-07-20 15:25:21)


http://i33.tinypic.com/2dt3j9j.gif

Offline

 

#816 2010-07-20 15:47:46

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

Re: Cool custom blocks in Scratch

I can give you some code to get

<place of %s in %L>

%s = textbox

%L = list


You can now reach me on Twitter @johnnydean1_

Offline

 

#817 2010-07-20 16:01:24

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

Re: Cool custom blocks in Scratch

Oh well I was bored so I made it anyway:
Name:
replace item %s of %L with %s

Type:
-

Block Spec:
('replace item %s of %L with %s'         #-      #replace:list:with: 'hi' 'list' 'hello')

Code:

replace: t1 list: t2 with: t3

| t4 t5 t6 t7|
t7_ 0.
t4_ 0.
t5_ self lineCountOfList: (t2).
t6_ ''.

t5 timesRepeat: [
t7_ t7 + 1.
t4_ self getLine: (t7) ofList: (t2).
t4 = t1
ifTrue: [

t6_ t7.
].
].
t6 = ''
ifTrue: [
t6_0.
]
ifFalse:[
t6_ t6.
self setLine: (t6) ofList: (t2) to: (t3). 
].

EDIT:
You may use the block in a mod but give credit to JD or JD1.

Last edited by johnnydean1 (2010-07-20 16:19:49)


You can now reach me on Twitter @johnnydean1_

Offline

 

#818 2010-07-20 16:10:04

Ralphjos
Scratcher
Registered: 2009-10-10
Posts: 100+

Re: Cool custom blocks in Scratch

Why thanks alot Johnny.  smile  I'm going to test it to see if it works.

Edit: It works! Thanks!  smile

Regards,
   Ralphjos

Last edited by Ralphjos (2010-07-21 06:46:11)


http://i33.tinypic.com/2dt3j9j.gif

Offline

 

#819 2010-07-20 16:16:38

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

Re: Cool custom blocks in Scratch

please call me JD or JD1


You can now reach me on Twitter @johnnydean1_

Offline

 

#820 2010-07-20 16:18:05

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

Re: Cool custom blocks in Scratch

Oh and by the way if the list you want is like

hi
yay

and you put in

replace hello in list with happy

Then it will not replace anything.


You can now reach me on Twitter @johnnydean1_

Offline

 

#821 2010-07-21 20:22:22

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

Re: Cool custom blocks in Scratch

johnnydean1 wrote:

Oh well I was bored so I made it anyway:
Name:
replace item %s of %L with %s

Type:
-

Block Spec:
('replace item %s of %L with %s'         #-      #replace:list:with: 'hi' 'list' 'hello')

Code:

replace: t1 list: t2 with: t3

| t4 t5 t6 t7|
t7_ 0.
t4_ 0.
t5_ self lineCountOfList: (t2).
t6_ ''.

t5 timesRepeat: [
t7_ t7 + 1.
t4_ self getLine: (t7) ofList: (t2).
t4 = t1
ifTrue: [

t6_ t7.
].
].
t6 = ''
ifTrue: [
t6_0.
]
ifFalse:[
t6_ t6.
self setLine: (t6) ofList: (t2) to: (t3). 
].

EDIT:
You may use the block in a mod but give credit to JD or JD1.

Why not just

Code:

self setLine: ((self listNamed: t2 ifNone: [^ self]) listContents indexOf: t1 ifAbsent: [^ self]) ofList: t2 to: t3

You don't need to give any credit for this one; and it's faster.

Last edited by nXIII (2010-07-21 20:22:48)


nXIII

Offline

 

#822 2010-07-22 20:31:41

honmeg287
Scratcher
Registered: 2009-07-28
Posts: 4

Re: Cool custom blocks in Scratch

i was unsuccesful with LS97's second post on the get time date block. please help!

Offline

 

#823 2010-07-22 20:33:10

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Cool custom blocks in Scratch

honmeg287 wrote:

i was unsuccesful with LS97's second post on the get time date block. please help!

Well, that code is completely legit, so I guess you'll just have to try again.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#824 2010-07-29 14:30:22

sonicjosh
Scratcher
Registered: 2007-10-28
Posts: 86

Re: Cool custom blocks in Scratch

Sperry wrote:

Theres a easier way than that!
Just use ('Hidden?' #b #isHidden)

Thanks!  big_smile  (I will say that for every block I use.)


http://i35.tinypic.com/14yacn6.jpg
Need help with your mod? Visit Mod Central!

Offline

 

#825 2010-07-29 15:03:57

sonicjosh
Scratcher
Registered: 2007-10-28
Posts: 86

Re: Cool custom blocks in Scratch

LS97 wrote:

The 'save stagearea to sprite' block
http://www.freeimagehosting.net/uploads/c8267d9caf.gif
I did this one on request of SeptimusHeap. it's maybe the easiest of the blocks. No coding needed, just add the block to the blockSpecs in ScratchSpriteMorph:

Code:

 ('save stage area to sprite' #- #grabFromScreen)

that's it! easy right?
PS. in case you didnt know, you have click accept.

Thanks for this too!  smile


http://i35.tinypic.com/14yacn6.jpg
Need help with your mod? Visit Mod Central!

Offline

 

Board footer