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

#2276 2011-10-28 16:52:21

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: ITopic: Welcome to your local block library!

Pecola1 wrote:

I think they mean any photos from weebly like:
http://www.weebly.com/images/new/logo.png

O.O I think they updated it, I think the images may work now!  smile

They do!   big_smile   big_smile   big_smile

Offline

 

#2277 2011-10-29 19:09:07

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: ITopic: Welcome to your local block library!

I have a question:  Why do we have <true> and <false> blocks in the library?  I've seen blocks get denied because of 2-block workarounds, yet there are many 1-block workarounds for these, without even having to change the arguments!

For true:
<( ) = ( )>
<not < >>

For false:
<( ) < ( )>
<( ) > ( )>
<< > and < >>
<< > or < >>

Does anyone know why we have them in the library?  It seems a little unfair to people who submitted blocks with 2-block workarounds...

Same for many other blocks (this is just from the Scratch section):
(error) = (0 / 0)
([1/10  v] as decimal = (1 / number)
<( ) is divisible by ( )> = <(number mod number) = 0>
(- ( )) = (-1 * number)
([1/2  v] of ( )) = ((number / number) * number)
<< > = < >> is not necessary, becuase booleans fit into <( ) = ( )>.
(< >) :  If this reports as a string, then it's not necessary because booleans fit into string arguments.
|go forward ( ) layers| = |go back (negative number) layers|, as stated in block entry
|if < > bounce| = if <boolean> { |turn (180) degrees| }

Please note that no offence is intended by this list.  I am merely asking as to why these blocks were accepted while others weren't.

Last edited by Greenatic (2011-10-29 19:27:23)

Offline

 

#2278 2011-10-30 05:28:16

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

Re: ITopic: Welcome to your local block library!

Of course I take no offence, it is a valid point. Personally, I believe that the reason that the true and false blocks were accepted is because firstly they are available in Panther, and secondly, and more importantly, true and false are boolean statements that appear in most every programming language and therefore are something Scratch is potentially missing.

Once I get the block library site up and running (its MySQL is causing no end of problems for me) this won't be a problem anymore since the search features will reduce the cluttering we would currently experience with the library at present since searching cannot be narrowed more that categories.

I'm off to work now, but when I get back I'll be sure to instate you as a full librarian, greenatic, I think you deserve it and would do well on the post!

Last edited by sparks (2011-10-30 05:28:35)


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

Offline

 

#2279 2011-10-30 13:12:34

zippynk
Scratcher
Registered: 2011-07-23
Posts: 500+

Re: ITopic: Welcome to your local block library!

This block allows you to do an infinite amount of things at once, due to the byob list input option.

Block Picture:

https://7699810775698828479-a-1802744773732722657-s-sites.googlegroups.com/site/zippynkscratchsite/home/image-cabinet/dotogetherpreviewpic.gif?attachauth=ANoY7crHod8KwqG3YN2M79KwynynHCh4YmhbtrwF9PBfHbmKYlncawwErpoJysN4ds8C7NSxyHcJk2wH0eP6ABmZ9_HWNFvLnSsAfvAegrelptUu8Y-JsxY6HFnfPJTbXbhwQgRo20VUsz7UxmwJDxHZNgkQQWCi4UfIRwcfUXsHUf4KwO43F5xevyj_X-SeqqRjdkIzsIhJ_JUyxzNddG9U6jDsLYyjnd3Om2v3UkA99aZyYF4dFnLBGXoZ345A2bv2Ddnw9qVV&amp;attredirects=0

Source Code:

https://7699810775698828479-a-1802744773732722657-s-sites.googlegroups.com/site/zippynkscratchsite/home/image-cabinet/dotogetherblock.gif?attachauth=ANoY7cqCU_dxERl3quIUluntFjBL2t7gLAwFuD4dCKuykX26zTuB5Ep3vkTBi_khLgfCVsTpcISej1mjSRFBeHHcBGJxqnNDFh3HBh8e1l4yxMUbjy7h8ttbYPa_7PXvJ2NwoBgCr2tROrNqYfwep8mAhifJz7Ay2ZxO7oSYBO6DXTXHwRX7lnoGIlmNlPQDTVCjv2J-2Thk88AjHnVVURr5ouYO_jmm2XM8sIqG-Q7rsTjZbEMGFtwybeH5qBoTkFvDvT_3Z0vq&amp;attredirects=1

Block Download Link (.ysp sprite):

Download This Block

What it does:
Runs multiple scripts at the same time.

Edit:
I just realized 2 things:
1) The links are broken.
2) Floppy_gunk already made this block.

Last edited by zippynk (2011-10-30 14:35:02)


https://dl.dropbox.com/u/60598636/trifocal_interlude_soundcloud_button.png

Offline

 

#2280 2011-10-30 19:21:12

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

Re: ITopic: Welcome to your local block library!

Greenatic wrote:

I have a question:  Why do we have <true> and <false> blocks in the library?  I've seen blocks get denied because of 2-block workarounds, yet there are many 1-block workarounds for these, without even having to change the arguments!

For true:
<( ) = ( )>
<not < >>

For false:
<( ) < ( )>
<( ) > ( )>
<< > and < >>
<< > or < >>

Does anyone know why we have them in the library?  It seems a little unfair to people who submitted blocks with 2-block workarounds...

Same for many other blocks (this is just from the Scratch section):
(error) = (0 / 0)
([1/10  v] as decimal = (1 / number)
<( ) is divisible by ( )> = <(number mod number) = 0>
(- ( )) = (-1 * number)
([1/2  v] of ( )) = ((number / number) * number)
<< > = < >> is not necessary, becuase booleans fit into <( ) = ( )>.
(< >) :  If this reports as a string, then it's not necessary because booleans fit into string arguments.
|go forward ( ) layers| = |go back (negative number) layers|, as stated in block entry
|if < > bounce| = if <boolean> { |turn (180) degrees| }

Please note that no offence is intended by this list.  I am merely asking as to why these blocks were accepted while others weren't.

[/blocks]
Almost all blocks have a workaround, even the ORIGINAL move () steps! The point is, does it help? See would it make it easier to use or use less blocks or even make it less messy? YES, these Boolean very much help messiness. And therefore the y are helpful and should be kept, thanks for pointing it out though.  big_smile

Last edited by Pecola1 (2011-10-30 19:22:03)


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

 

#2281 2011-10-30 22:27:05

zippynk
Scratcher
Registered: 2011-07-23
Posts: 500+

Re: ITopic: Welcome to your local block library!

Requesting block:

stop all but this script

Type of block:
Stack Block

Requested for:
Any program it would work in

What it would do:
Stop all scripts but the one it's in, then keep going.

Please tell me if you think it's possible. Thanks!

-zippynk


https://dl.dropbox.com/u/60598636/trifocal_interlude_soundcloud_button.png

Offline

 

#2282 2011-10-31 10:01:38

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

Re: ITopic: Welcome to your local block library!

zippynk wrote:

Requesting block:

stop all but this script

Type of block:
Stack Block

Requested for:
Any program it would work in

What it would do:
Stop all scripts but the one it's in, then keep going.

Please tell me if you think it's possible. Thanks!

-zippynk

I think you mean cap.  wink


I'm BACK!! :DDD
No need to replace me.  tongue
And Greenatic, congrats on getting Librarian status!

Last edited by scimonster (2011-10-31 10:02:01)

Offline

 

#2283 2011-10-31 10:14:01

YourLocalBlockLib
Scratcher
Registered: 2011-03-10
Posts: 100+

Re: ITopic: Welcome to your local block library!

.                              http://welcometoyourlocalblocklibrary.weebly.com/uploads/7/1/1/0/7110842/292223741.gif

Updates: [2]
TheSuccessor quit as a Block Librarian.
Greenatic was hired to replace TheSuccessor as a Librarian.

Update carried out by all block librarians, past and present
________________________________________________________________________________
^home


http://dl.dropbox.com/u/6273449/BlockLibraryTitle.png

Offline

 

#2284 2011-10-31 10:35:45

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

Re: ITopic: Welcome to your local block library!

Welcome back, sci! I'll arrange the sending of the password to Greenatic. I can use the Scratch API to link him to a login page for the information  smile


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

Offline

 

#2285 2011-10-31 13:40:41

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

Re: ITopic: Welcome to your local block library!

Greenatic, you can now log in on the block library site and receive all your information here! Let me know when you're done so I can remove the page!


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

Offline

 

#2286 2011-10-31 17:03:29

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

Re: ITopic: Welcome to your local block library!

scimonster wrote:

zippynk wrote:

Requesting block:

stop all but this script

Type of block:
Stack Block

Requested for:
Any program it would work in

What it would do:
Stop all scripts but the one it's in, then keep going.

Please tell me if you think it's possible. Thanks!

-zippynk

I think you mean cap.  wink

A cap block IS a stack block. Only there is an extra code for the cap/end blocks.  big_smile


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

 

#2287 2011-10-31 18:33:02

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: ITopic: Welcome to your local block library!

Sparks, you can remove that now.   smile

I'm honored to receive this position and appreciate all those who nominated me.  Thank you!

BTW, I'm not exactly sure how the numbered blocks for the statistics are produced.  Do they have to be uploaded manually each time?

@Scimonster--What was the last Scratch block you added?  I can't seem to find the update...
EDIT: Never mind, I found it on page 80.  It only affected blocks through the second post of page 72.   hmm

I would like to propose the addition of a simple new feature at the first post:  A list of all available dropdowns.  Dropdowns are commonly used and this would make it quick and easy for contributors.  Furthermore, it would be easy to update.  What are your opinions on a list like this?

I believe the list for Scratch Blocks is as follows:

A
B
E
F
J
K
O
o
P
p
q
R
t
U
u
V
w

Last edited by Greenatic (2011-11-08 15:33:29)

Offline

 

#2288 2011-10-31 19:52:28

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: ITopic: Welcome to your local block library!

I am now proceeding to combine the various list blocks made earlier into two blocks.  I will post the code here in case another librarian happens to be able to perform an update before me.  "Mode(s) of" will remain a seperate block, since it takes an extra argument.

EDIT:  The two megablocks have now been combined.

http://www.freewebs.com/polyeztahpuppies/averageoflist.gif

Code:

 ('%Y of %L' #r #Math:List: 'mean' 'list')

Code:

Math: t1 List: t2
| max min line sum t3 t4 a |
t1 = 'maximum' ifTrue:[
(self lineCountOfList: t2) asNumberNoError = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    max _ (self getLine: 1 ofList: t2) asNumberNoError.
    line _ 2.
    (self lineCountOfList: t2) asNumberNoError - 1
        timesRepeat: 
            [(self getLine: line ofList: t2) asNumberNoError > max ifTrue: [max _ (self getLine: line ofList: t2) asNumberNoError].
            line _ line + 1].
    ^ max].
t1 = 'minimum' ifTrue:[
(self lineCountOfList: t2) asNumberNoError = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    min _ (self getLine: 1 ofList: t2) asNumberNoError.
    line _ 2.
    (self lineCountOfList: t2) asNumberNoError - 1
        timesRepeat: 
            [(self getLine: line ofList: t2) asNumberNoError < min ifTrue: [min _ (self getLine: line ofList: t2) asNumberNoError].
            line _ line + 1].
    ^ min].
t1 = 'mean' ifTrue:[
 (self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ self getLine: 1 ofList: t2].
   (self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    t3 _ 2.
    sum _ (self getLine: 1 ofList: t2) asNumberNoError.
    (self lineCountOfList: t2)
        - 1
        timesRepeat: 
            [sum _ sum + (self getLine: t3 ofList: t2) asNumberNoError.
            t3 _ t3 + 1].
    ^ sum
        / (self lineCountOfList: t2)].
t1 = 'range' ifTrue:[
    (self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
        (self lineCountOfList: t2)
        = 1 ifTrue: [^ 0].
    (self lineCountOfList: t2) asNumberNoError = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    max _ (self getLine: 1 ofList: t2) asNumberNoError.
    line _ 2.
    (self lineCountOfList: t2) asNumberNoError - 1
        timesRepeat: 
            [(self getLine: line ofList: t2) asNumberNoError > max ifTrue: [max _ (self getLine: line ofList: t2) asNumberNoError].
            line _ line + 1].
    (self lineCountOfList: t2) asNumberNoError = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    min _ (self getLine: 1 ofList: t2) asNumberNoError.
    line _ 2.
    (self lineCountOfList: t2) asNumberNoError - 1
        timesRepeat: 
            [(self getLine: line ofList: t2) asNumberNoError < min ifTrue: [min _ (self getLine: line ofList: t2) asNumberNoError].
            line _ line + 1].
    ^ max - min].
t1 = 'median' ifTrue:[
(self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    t3 _ #() asOrderedCollection.
    t4 _ 1.
    (self lineCountOfList: t2)
        timesRepeat: 
            [t3 add: (self getLine: t4 ofList: t2) asNumberNoError.
            t4 _ t4 + 1].
    t3 _ t3 asArray sort.
    t3 _ t3 asOrderedCollection.
    [t3 size > 2]
        whileTrue: 
            [t3 removeAt: 1.
            t3 removeAt: t3 size].
    t3 size = 1 ifTrue: [^ t3 at: 1].
    ^ (t3 at: 1)
        + (t3 at: 2) / 2].
t1 = 'sum' ifTrue:[
(self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    t3 _ 2.
    a _ (self getLine: 1 ofList: t2) asNumberNoError.
    (self lineCountOfList: t2)
        - 1
        timesRepeat: 
            [a _ a + (self getLine: t3 ofList: t2) asNumberNoError.
            t3 _ t3 + 1].
    ^ a].
t1 = 'difference' ifTrue:[
(self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    t3 _ 2.
    a _ (self getLine: 1 ofList: t2) asNumberNoError.
    (self lineCountOfList: t2)
        - 1
        timesRepeat: 
            [a _ a - (self getLine: t3 ofList: t2) asNumberNoError.
            t3 _ t3 + 1].
    ^ a].
t1 = 'product' ifTrue:[
(self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    t3 _ 2.
    a _ (self getLine: 1 ofList: t2) asNumberNoError.
    (self lineCountOfList: t2)
        - 1
        timesRepeat: 
            [a _ a * (self getLine: t3 ofList: t2) asNumberNoError.
            t3 _ t3 + 1].
    ^ a].
t1 = 'quotient' ifTrue:[
(self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    t3 _ 2.
    a _ (self getLine: 1 ofList: t2) asNumberNoError.
    (self lineCountOfList: t2)
        - 1
        timesRepeat: 
            [a _ a / (self getLine: t3 ofList: t2) asNumberNoError.
            t3 _ t3 + 1].
    ^ a].

ScriptableScratchMorph > list ops

Code:

listMath
    ^ #('mean' 'median' #- 'maximum' 'minimum' 'range' #- 'sum' 'difference' 'product' 'quotient' )

Scratch-Blocks> CommandBlockMorph> private> uncoloredArgMorphFor:  add:

Code:

$Y = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #listMath;
choice: 'mean'].

Scratch-Objects > Scriptable Scratch Morph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):

Code:

 #Math:List: = t4
        ifTrue: [t2 size >= 2 ifTrue: [t2 at: 1 put: (t2 at: 1) localized.
t2 at: 2 put: self defaultListName]].

Last edited by Greenatic (2011-11-10 21:54:22)

Offline

 

#2289 2011-11-01 04:25:08

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

Re: ITopic: Welcome to your local block library!

Greenatic wrote:

BTW, I'm not exactly sure how the numbered blocks for the statistics are produced.  Do they have to be uploaded manually each time?

Nope!
Just change the "spec=" or whatever.  wink

Offline

 

#2290 2011-11-01 05:49:33

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

Re: ITopic: Welcome to your local block library!

scimonster wrote:

Greenatic wrote:

BTW, I'm not exactly sure how the numbered blocks for the statistics are produced.  Do they have to be uploaded manually each time?

Nope!
Just change the "spec=" or whatever.  wink

Do you mean the number block in the first post showing how many blocks are in each category? Yes, they need manual changing. After adding a block (or set of blocks) you need to change all relevant numbers in the home page and stats page, as well as changing the numbers next to sharer names, adding new names if there are any and changing the "top submitter" for the category if need be.


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

Offline

 

#2291 2011-11-01 09:42:37

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

Re: ITopic: Welcome to your local block library!

SSBBM wrote:

sparks wrote:

I'm not sure more is the right term, perhapse it might be worth asking those librarians who haven't been very active if they truly feel they have the time at the moment and then if any step down - even temporarily, we can look for suitable replacements?

I feel that I'm not active. I would be willing to step down if other felt the need.

Nobody really gave their input on this


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

Offline

 

#2292 2011-11-01 10:02:26

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

Re: ITopic: Welcome to your local block library!

Whoops, sorry SSBBM. Do you want to resign? There's no need to if you don't want to, and providing there is space you'd always be welcome to rejoin.


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

Offline

 

#2293 2011-11-01 10:16:45

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: ITopic: Welcome to your local block library!

I made some shorter code for the (letter (10) of the alphabet) block:

Code:

letter: t1 
    | t2 |
    t2 _ t1 asNumberNoError.
    (t2 < 1 or: [t2 > 26])
        ifTrue: [self errorFlag].
    ^ String with: (Character value: t2 asNumberNoError + 96)

http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#2294 2011-11-01 10:39:48

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: ITopic: Welcome to your local block library!

Shorter code for the <Am I on [costume1]?> block.

Code:

onCostume: t1
^ t1 = (self costumeNameFromNumber: self costumeIndex).

Shorter code for [Switch whether hidden or shown]. "toggle visibility" would be a better name IMO.

Code:

switchHide
self isHidden: self isHidden not.

Shorter code for the (Number of costumes) block.

Code:

^ (media reject: [:t4 | t4 isSound]) size

I could go on... :P

No code is needed for the (my name) block, just change the block specs to ('my name' #r #objName).

<<> = <>> is xor and does the same thing as <[] = []>.

Last edited by MathWizz (2011-11-01 11:12:11)


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#2295 2011-11-01 10:49:40

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

Re: ITopic: Welcome to your local block library!

MathWizz wrote:

I could go on...  tongue

I'm sure you could.  tongue

Offline

 

#2296 2011-11-01 11:14:17

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

Re: ITopic: Welcome to your local block library!

sparks wrote:

Whoops, sorry SSBBM. Do you want to resign? There's no need to if you don't want to, and providing there is space you'd always be welcome to rejoin.

I'll resign if others fell the need, but I don't necessarily want to. As I said I don't fell like I'm active and so it might be better if I officially resign and someone with more free time take my place.


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

Offline

 

#2297 2011-11-01 13:40:06

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

Re: ITopic: Welcome to your local block library!

Greenatic wrote:

I am now proceeding to combine the various list blocks made earlier into two blocks.  I will post the code here in case another librarian happens to be able to perform an update before me.  "Mode(s) of" will remain a seperate block, since it takes an extra argument.

http://www.freewebs.com/polyeztahpuppie … oflist.gif

Code:

('%Z of %L' #r #MathOp:List: 'sum' 'list')

Code:

MathOp: t1 List: t2
| t3 a |
t1 = 'sum' ifTrue:[
(self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    t3 _ 2.
    a _ (self getLine: 1 ofList: t2) asNumberNoError.
    (self lineCountOfList: t2)
        - 1
        timesRepeat: 
            [a _ a + (self getLine: t3 ofList: t2) asNumberNoError.
            t3 _ t3 + 1].
    ^ a].
t1 = 'difference' ifTrue:[
(self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    t3 _ 2.
    a _ (self getLine: 1 ofList: t2) asNumberNoError.
    (self lineCountOfList: t2)
        - 1
        timesRepeat: 
            [a _ a - (self getLine: t3 ofList: t2) asNumberNoError.
            t3 _ t3 + 1].
    ^ a].
t1 = 'product' ifTrue:[
(self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    t3 _ 2.
    a _ (self getLine: 1 ofList: t2) asNumberNoError.
    (self lineCountOfList: t2)
        - 1
        timesRepeat: 
            [a _ a * (self getLine: t3 ofList: t2) asNumberNoError.
            t3 _ t3 + 1].
    ^ a].
t1 = 'quotient' ifTrue:[
(self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    t3 _ 2.
    a _ (self getLine: 1 ofList: t2) asNumberNoError.
    (self lineCountOfList: t2)
        - 1
        timesRepeat: 
            [a _ a / (self getLine: t3 ofList: t2) asNumberNoError.
            t3 _ t3 + 1].
    ^ a].

ScriptableScratchMorph > list ops

Code:

listMath
    ^ #('sum' 'difference' 'product' 'quotient' )

Scratch-Blocks> CommandBlockMorph> private> uncoloredArgMorphFor:  add:

Code:

$Z = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #listMath;
choice: 'sum'].

Scratch-Objects > Scriptable Scratch Morph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):

Code:

#MathOp:List: = t4
        ifTrue: [t2 size >= 2 ifTrue: [t2 at: 1 put: (t2 at: 1) localized.
t2 at: 2 put: self defaultListName]].

http://www.freewebs.com/polyeztahpuppie … oflist.gif

Code:

 ('%Y of %L' #r #Average:List: 'mean' 'list')

Code:

Average: t1 List: t2
| max min line sum t3 t4 |
t1 = 'maximum' ifTrue:[
(self lineCountOfList: t2) asNumberNoError = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    max _ (self getLine: 1 ofList: t2) asNumberNoError.
    line _ 2.
    (self lineCountOfList: t2) asNumberNoError - 1
        timesRepeat: 
            [(self getLine: line ofList: t2) asNumberNoError > max ifTrue: [max _ (self getLine: line ofList: t2) asNumberNoError].
            line _ line + 1].
    ^ max].
t1 = 'minimum' ifTrue:[
(self lineCountOfList: t2) asNumberNoError = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    min _ (self getLine: 1 ofList: t2) asNumberNoError.
    line _ 2.
    (self lineCountOfList: t2) asNumberNoError - 1
        timesRepeat: 
            [(self getLine: line ofList: t2) asNumberNoError < min ifTrue: [min _ (self getLine: line ofList: t2) asNumberNoError].
            line _ line + 1].
    ^ min].
t1 = 'mean' ifTrue:[
 (self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ self getLine: 1 ofList: t2].
   (self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    t3 _ 2.
    sum _ (self getLine: 1 ofList: t2) asNumberNoError.
    (self lineCountOfList: t2)
        - 1
        timesRepeat: 
            [sum _ sum + (self getLine: t3 ofList: t2) asNumberNoError.
            t3 _ t3 + 1].
    ^ sum
        / (self lineCountOfList: t2)].
t1 = 'range' ifTrue:[
    (self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
        (self lineCountOfList: t2)
        = 1 ifTrue: [^ 0].
    (self lineCountOfList: t2) asNumberNoError = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    max _ (self getLine: 1 ofList: t2) asNumberNoError.
    line _ 2.
    (self lineCountOfList: t2) asNumberNoError - 1
        timesRepeat: 
            [(self getLine: line ofList: t2) asNumberNoError > max ifTrue: [max _ (self getLine: line ofList: t2) asNumberNoError].
            line _ line + 1].
    (self lineCountOfList: t2) asNumberNoError = 0 ifTrue: [^ 0].
    (self lineCountOfList: t2)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t2) asNumberNoError].
    min _ (self getLine: 1 ofList: t2) asNumberNoError.
    line _ 2.
    (self lineCountOfList: t2) asNumberNoError - 1
        timesRepeat: 
            [(self getLine: line ofList: t2) asNumberNoError < min ifTrue: [min _ (self getLine: line ofList: t2) asNumberNoError].
            line _ line + 1].
    ^ max - min].
t1 = 'median' ifTrue:[
(self lineCountOfList: t2)
        = 0 ifTrue: [^ 0].
    t3 _ #() asOrderedCollection.
    t4 _ 1.
    (self lineCountOfList: t2)
        timesRepeat: 
            [t3 add: (self getLine: t4 ofList: t2) asNumberNoError.
            t4 _ t4 + 1].
    t3 _ t3 asArray sort.
    t3 _ t3 asOrderedCollection.
    [t3 size > 2]
        whileTrue: 
            [t3 removeAt: 1.
            t3 removeAt: t3 size].
    t3 size = 1 ifTrue: [^ t3 at: 1].
    ^ (t3 at: 1)
        + (t3 at: 2) / 2].

ScriptableScratchMorph > list ops

Code:

listAverages
    ^ #('mean' 'median' #- 'maximum' 'minimum' 'range' )

Scratch-Blocks> CommandBlockMorph> private> uncoloredArgMorphFor:  add:

Code:

$Y = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #listAverages;
choice: 'mean'].

Scratch-Objects > Scriptable Scratch Morph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):

Code:

 #Average:List: = t4
        ifTrue: [t2 size >= 2 ifTrue: [t2 at: 1 put: (t2 at: 1) localized.
t2 at: 2 put: self defaultListName]].

Should these be put into the same block? Sure they are different but they use the same block spec. What do others think?


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

 

#2298 2011-11-01 18:11:58

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: ITopic: Welcome to your local block library!

@sparks:  Thanks, that's what I needed to know.  I also left a comment on one of your projects with a question about the account's main site messages.
@Pecola1:  I would be willing to consider that.  What does everyone else think?

Offline

 

#2299 2011-11-01 19:40:34

zippynk
Scratcher
Registered: 2011-07-23
Posts: 500+

Re: ITopic: Welcome to your local block library!

scimonster wrote:

zippynk wrote:

Requesting block:

stop all but this script

Type of block:
Stack Block

Requested for:
Any program it would work in

What it would do:
Stop all scripts but the one it's in, then keep going.

Please tell me if you think it's possible. Thanks!

-zippynk

I think you mean cap.  wink

No, because a cap would stop the script. This would stop all scripts Except for the current one.

Last edited by zippynk (2011-11-01 19:40:59)


https://dl.dropbox.com/u/60598636/trifocal_interlude_soundcloud_button.png

Offline

 

#2300 2011-11-01 21:11:13

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

Re: ITopic: Welcome to your local block library!

zippynk wrote:

scimonster wrote:

zippynk wrote:

Requesting block:

stop all but this script

Type of block:
Stack Block

Requested for:
Any program it would work in

What it would do:
Stop all scripts but the one it's in, then keep going.

Please tell me if you think it's possible. Thanks!

-zippynk

I think you mean cap.  wink

No, because a cap would stop the script. This would stop all scripts Except for the current one.

LOL never thought of that.


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