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

#1201 2011-06-13 07:13:33

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: ITopic: Welcome to your local block library!

ssss wrote:

Hi sparks, I was wonderring if you could help me make a random block generator.  What it would do is find a block on the Local block library, and display it.  All credit would be given of course, but is it doable?

Well this will work: You just take the current block download code and set t1 to a random variable at the start:

Code:

download random block from the block library

Code:

|maker link t1 t2 t3 t4|
t1_ self randomFrom: 1 to: 59.
link_'http://dl.dropbox.com/u/6273449/', t1 asString, '.txt'.
maker_self readLine: 1 FromUrl: link.
t1_self readLine: 2 FromUrl: link.
t2_self readLine: 3 FromUrl: link.
t4_self readLine: 4 FromUrl: link.
t4_self stringAsColor: t4.
t3_self readLine: 5 FromUrl: link.

createdBlocks at: t1 put: {t1. t1. '-'. ''. self class blockColorFor: 'custom'}.createdBlocks at: t1 put: {t1. t1. t2. t3. t4}.(t4 _ self ownerThatIsA: ScratchFrameMorph) ifNotNil: [t4 viewerPane categoryChanged: 'variables'].

self showInformDialog: 'Sucess!' withText: 'The block has been added to your variables tab.', '
', 'The "', t1, '" block', '
', ' was shared by ', maker

note the "t1_ self randomFrom: 1 to: 59." on line two of the code! The only problem with this is that when more blocks are added to the library they will not be shown by this block unless you change the 59 to a new number. It might be possible to increment a counter until trying to read a block returns an error page but I'll leave you to research that!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#1202 2011-06-13 07:16:42

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: ITopic: Welcome to your local block library!

sparks wrote:

ssss wrote:

Hi sparks, I was wonderring if you could help me make a random block generator.  What it would do is find a block on the Local block library, and display it.  All credit would be given of course, but is it doable?

Well this will work: You just take the current block download code and set t1 to a random variable at the start:

Code:

download random block from the block library

Code:

|maker link t1 t2 t3 t4|
t1_ self randomFrom: 1 to: 59.
link_'http://dl.dropbox.com/u/6273449/', t1 asString, '.txt'.
maker_self readLine: 1 FromUrl: link.
t1_self readLine: 2 FromUrl: link.
t2_self readLine: 3 FromUrl: link.
t4_self readLine: 4 FromUrl: link.
t4_self stringAsColor: t4.
t3_self readLine: 5 FromUrl: link.

createdBlocks at: t1 put: {t1. t1. '-'. ''. self class blockColorFor: 'custom'}.createdBlocks at: t1 put: {t1. t1. t2. t3. t4}.(t4 _ self ownerThatIsA: ScratchFrameMorph) ifNotNil: [t4 viewerPane categoryChanged: 'variables'].

self showInformDialog: 'Sucess!' withText: 'The block has been added to your variables tab.', '
', 'The "', t1, '" block', '
', ' was shared by ', maker

note the "t1_ self randomFrom: 1 to: 59." on line two of the code! The only problem with this is that when more blocks are added to the library they will not be shown by this block unless you change the 59 to a new number. It might be possible to increment a counter until trying to read a block returns an error page but I'll leave you to research that!

But it's not to download  hmm   It's to show on the page [url]www.cyberkidscountry.com/s360.html[/img]  where it should show code & the ('Block code thing' #-) as well as an image.   hmm   So I need to use JS or html/css  hmm


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#1203 2011-06-13 07:16:47

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: ITopic: Welcome to your local block library!

... I realise I may have misunderstood. Did you want this to display a block from the library using php on a webpage?


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#1204 2011-06-13 07:17:46

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: ITopic: Welcome to your local block library!

sparks wrote:

... I realise I may have misunderstood. Did you want this to display a block from the library using php on a webpage?

Yes.  That's exactly what I want to do!  It should show, code ('This thing' #- #-) and an image!   wink


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#1205 2011-06-13 07:28:48

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

Re: ITopic: Welcome to your local block library!

http://theblocklibrary.site11.com/include/img/blocks/specparser.php?spec=Well,%20you%20can%20use%20this%20for%20the%20image...&type=reporter&color=files
http://theblocklibrary.site11.com/include/img/blocks/specparser.php?spec=@TheSuccessor:%20You%20PWN!!!!!!&type=boolean&color=control

Offline

 

#1206 2011-06-13 07:30:18

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: ITopic: Welcome to your local block library!

Hmm.... I'm not certain how to read lines from other webpages into php variables... I've never needed to do that... But as Scimonster says above, you can use TheSucessor's block generator to display the image!


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#1207 2011-06-13 07:32:11

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: ITopic: Welcome to your local block library!

sparks wrote:

Hmm.... I'm not certain how to read lines from other webpages into php variables... I've never needed to do that... But as Scimonster says above, you can use TheSucessor's block generator to display the image!

hmm   But I wanted it to display a random block each time  hmm
I think I have to use something like a website with all the images, codes, and blockspecs sorted -_-  Great...  I'll probably have to do it all manually  sad


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#1208 2011-06-13 07:36:21

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

Re: ITopic: Welcome to your local block library!

http://theblocklibrary.site11.com/include/img/blocks/specparser.php?spec=Can%27t%20PHP%20give%20a%20random%20number?&type=color&color=motion

Offline

 

#1209 2011-06-13 07:40:45

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: ITopic: Welcome to your local block library!

Do you understans what i want it to do?:

1.  It gets (and displays) the Blockspecs
2.  It gets (and displays) the code
3. It finds and displays the image renderred by the blockspec.


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#1210 2011-06-13 07:49:00

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

Re: ITopic: Welcome to your local block library!

Get the source of the block lib page, and find the spec, code, and image.  wink

Offline

 

#1211 2011-06-13 07:52:16

wulfmaster
Scratcher
Registered: 2011-04-23
Posts: 500+

Re: ITopic: Welcome to your local block library!

scimonster wrote:

Get the source of the block lib page, and find the spec, code, and image.  wink

How difficult would that be?

Funnily enough, the countdown for the 360 second rule is actually pretty accurate 0.o


Social Connections - Bringing communities close together! http://cyberkidscountry.com/ip.php

Offline

 

#1212 2011-06-13 08:06:19

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

Re: ITopic: Welcome to your local block library!

I don't know PHP (yet), so: idk.

Offline

 

#1213 2011-06-13 08:07:41

wulfmaster
Scratcher
Registered: 2011-04-23
Posts: 500+

Re: ITopic: Welcome to your local block library!

scimonster wrote:

I don't know PHP (yet), so: idk.

Alright, thanks for the help!

(For now, I'm working on a Scratch project!)


Social Connections - Bringing communities close together! http://cyberkidscountry.com/ip.php

Offline

 

#1214 2011-06-13 10:20:04

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

Re: ITopic: Welcome to your local block library!

TheSuccessor wrote:

Pecola1 wrote:

OMG! TheSuccessor just gave me an idea!
I have a new block...
http://www.weebly.com/uploads/7/1/1/0/7 … 770768.gif

Blockspec
('stop all scripts for %m' #- #stopAllScriptsFor: 'Stage')

Code:

stopAllScriptsFor: t1 
t1 stopAllMine

You first have to make the code that TheSuccessor made. e.g.

Code:

stopAllMine
    self scripts do: [:t1 | t1 stop]

I don't have time to add it plus it might be better if we just save up blocks for a bigger update than just 1 block.  tongue

I think you might have to do this instead for the method:

Code:

stopAllScriptsFor: t1
(self coerceSpriteArg: t1) stopAllMine

The sprite name could be a string, so we have to use coerceSpriteArg: to make it a sprite.

Without my block, just do this:

Code:

stopAllScriptsFor: t1
(self coerceSpriteArg: t1) scripts do: [:t1 | t1 stop]

I didn't think of that. XD Thanks.

Last edited by Pecola1 (2011-06-13 10:33:30)


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

 

#1215 2011-06-13 15:30:57

pokemongardevoir
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: ITopic: Welcome to your local block library!

Once i open the browser how do i add the code for the custom block?


http://i48.tinypic.com/n50dt.gifhttp://tiny.cc/oj6plwhttp://tiny.cc/creepforum
My website has been approved by the Scratch Team.  (^_^)

Offline

 

#1216 2011-06-13 15:39:42

SSBBM
Scratcher
Registered: 2009-10-09
Posts: 100+

Re: ITopic: Welcome to your local block library!

pokemongardevoir wrote:

Once i open the browser how do i add the code for the custom block?

Scratch, BYOB, or Panther blocks?


http://goo.gl/zVfAp http://goo.gl/laci8

Offline

 

#1217 2011-06-13 17:55:54

TuragaTreeko
Scratcher
Registered: 2011-04-24
Posts: 100+

Re: ITopic: Welcome to your local block library!

NOW ADAPTED TO SCRATCH!!!!
Here is the user page block by sparks, changed from Panther to Scratch. This is my own code, so I can't guarantee it will work. I tried it and it SEEMED to work, but... you know.

blockspecs: ('open "my stuff" page for Scratch user %s' #- #doOpenForUser: scimonster)

ops: openForUser: t1
    cursor wait showWhile ScratchPlugin primOpen URL: http://scratch.mit.edu/users/ t1

I hope this works!


http://goo.gl/RDqKF

Offline

 

#1218 2011-06-13 18:58:13

ruaqt3
Scratcher
Registered: 2010-08-22
Posts: 1

Re: ITopic: Welcome to your local block library!

/Users/cindydickens/Desktop/byob block.gif/Users/cindydickens/Desktop/block edit.gif

Offline

 

#1219 2011-06-13 19:35:27

EzekielE
Scratcher
Registered: 2010-09-26
Posts: 100+

Re: ITopic: Welcome to your local block library!

ruaqt3 wrote:

/Users/cindydickens/Desktop/byob block.gif/Users/cindydickens/Desktop/block edit.gif

You have to upload it with something like imgur.com


http://mag.racked.eu/cimage/i2260/Achievement++get%21/Find+a+Disk/mca.pnghttp://ezekielelin.com/1x1Gif/image.php

Offline

 

#1220 2011-06-13 19:49:16

pokemongardevoir
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: ITopic: Welcome to your local block library!

SSBBM wrote:

pokemongardevoir wrote:

Once i open the browser how do i add the code for the custom block?

Scratch, BYOB, or Panther blocks?

Scratch, I think. (The open URL block)


http://i48.tinypic.com/n50dt.gifhttp://tiny.cc/oj6plwhttp://tiny.cc/creepforum
My website has been approved by the Scratch Team.  (^_^)

Offline

 

#1221 2011-06-13 20:27:59

TuragaTreeko
Scratcher
Registered: 2011-04-24
Posts: 100+

Re: ITopic: Welcome to your local block library!

pokemongardevoir wrote:

SSBBM wrote:

pokemongardevoir wrote:

Once i open the browser how do i add the code for the custom block?

Scratch, BYOB, or Panther blocks?

Scratch, I think. (The open URL block)

Okay, go to blockspecs. This is where you confirm the block exists, and you tell what it looks like. You also name the action it does.

for the URL block, I would do this (this is the blockspecs scimonster gave me):
('open URL: %s' #- #doOpen: )

the part in quotes is what the block says on it. the %s is a place for a string. #- means it is a stack block. #doOpen names the action open.

right click and choose accept, and go to instance. under other ops, replace the code of the broadcast with

open: t1
       cursor wait showWhile ScratchPlugin primOpen URL: t1

or something like that. I think there is actually a bracket in there somewhere. anywho, that is how you code a block.

Oh, and awesome username (gardevoir is one of my faves -- treecko is my absolute favorite).

smile


http://goo.gl/RDqKF

Offline

 

#1222 2011-06-14 05:09:43

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

Re: ITopic: Welcome to your local block library!

TuragaTreeko, you need quotes around strings for default values.

you wrote:

blockspecs: ('open "my stuff" page for Scratch user %s' #- #doOpenForUser: scimonster)

ops: openForUser: t1
    cursor wait showWhile ScratchPlugin primOpen URL: http://scratch.mit.edu/users/ t1

This won't work. You need:
blockspecs: ('open "my stuff" page for Scratch user %s' #- #OpenUser: 'scimonster')

ops:
openUser: t1
    Cursor wait showWhile: [ScratchPlugin primOpenURL: 'http://scratch.mit.edu/users/' , t1]

Offline

 

#1223 2011-06-14 15:29:55

TuragaTreeko
Scratcher
Registered: 2011-04-24
Posts: 100+

Re: ITopic: Welcome to your local block library!

Haha, woops. I guess that wasn't as good as I hoped it would be. I'm not all that good at this. But I WILL keep trying! I'm determined.



did you notice I used you as the default value?  smile


http://goo.gl/RDqKF

Offline

 

#1224 2011-06-14 16:57:39

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

Re: ITopic: Welcome to your local block library!

TuragaTreeko wrote:

Haha, woops. I guess that wasn't as good as I hoped it would be. I'm not all that good at this. But I WILL keep trying! I'm determined.



did you notice I used you as the default value?  smile

Once you get better you wont make as many mistakes.  smile  But notice I said, "as many"  tongue  I make a lot of mistakes still. XD I just recently compleatly forgot to put 'self' before commands for a whole script I was making.  lol   roll  You may not make as many mistakes as I do.


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

 

#1225 2011-06-14 17:14:40

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

Re: ITopic: Welcome to your local block library!

OMG! The block library has 112 pages!  yikes  Isn't that weird? Its so looooong.


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

 

Board footer