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

#1776 2011-07-29 13:04:15

mrsrec
Scratcher
Registered: 2010-11-14
Posts: 100+

Re: ITopic: Welcome to your local block library!

Slash Block

http://scriptingthing.weebly.com/uploads/6/6/1/8/6618874/a.gif

Cool,Huh?


Scratchy Scratcher Scratched Scratch Scratches When He Scratchy Scratches Scratch Projects. These Scratch Projects Were Started From Scratch.
http://internetometer.com/image/37716.png

Offline

 

#1777 2011-07-30 13:56:21

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

Re: ITopic: Welcome to your local block library!

3 new blocks!

http://polyeztahpuppies.webs.com/movetowards.gif

Note:  I saw a suggestion for this in the Suggestions forum and decided to make it.  While at first it might seem like it just does the following:

When Green Flag Clicked
forever {
point towards [    v].
move ( ) steps. }

The advantage of this is that this doesn't affect direction, allowing you to use direction for something else.

Code:

('move %n steps towards %m' #- #Move:Towards:)

Code:

Move: t1 Towards: t2 
    | t3 t4 t5 t6 t7 t8 t9 |
    t2 = #mouse ifFalse: [t3 _ t2 xpos @ t2 ypos - self referencePosition].
    t2 = #mouse ifTrue: [t3 _ self mouseX rounded @ self mouseY - self referencePosition].
    t4 _ t3 x abs < 0.001
                ifTrue: [t3 y < 0
                        ifTrue: [90]
                        ifFalse: [270]]
                ifFalse: [((t3 x >= 0
                        ifTrue: [0]
                        ifFalse: [180])
                        - ((t3 y / t3 x) arcTan * 57.2957795131)) rounded].
    t5 _ t4 degreesToRadians.
    t6 _ t5 cos @ t5 sin * t1.
    t7 _ self position + t6.
    t8 _ t7 x.
    t9 _ t7 y.
    t8 isNaN ifTrue: [t8 _ 0].
    t8 isInf ifTrue: [t8 _ t8 sign * 10000].
    t9 isNaN ifTrue: [t9 _ 0].
    t9 isInf ifTrue: [t9 _ t9 sign * 10000].
    self position: t8 @ t9.
    self keepOnScreen

http://polyeztahpuppies.webs.com/fontexists.gif

***Credit note:  Improved by Baderous.***

Code:

('font %s exists?' #b #FontExists:)

Code:

FontExists: t1 
    | t2 |
    t2 _ UnicodePlugin getFontList collect: [:f | f asUTF8].
    ^ t2 includes: t1

http://polyeztahpuppies.webs.com/importfonts.gif

***Credit note:  Improved by LS97 and Baderous.***

Code:

('import fonts to list %L' #- #FontstoList: 'list')

Method code:

Code:

FontstoList: t1 
    | t2 |
    t2 _ UnicodePlugin getFontList.
    t2 do: [:t3 | self append: t3 toList: t1]

Scratch-Objects > Scriptable Scratch Morph > blocks > defaultArgsFor:

Add right before the last line ( ^ t2 ):

Code:

#FontstoList: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

Offline

 

#1778 2011-07-30 17:14:40

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

Re: ITopic: Welcome to your local block library!

4 more blocks:

http://polyeztahpuppies.webs.com/sumoflist.gif

Code:

('sum of items of %L' #r #SumOf: 'list')

Method code:

Code:

SumOf: t1 
    | t2 a |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    t2 _ 2.
    a _ (self getLine: 1 ofList: t1) asNumberNoError.
    (self lineCountOfList: t1)
        - 1
        timesRepeat: 
            [a _ a + (self getLine: t2 ofList: t1) asNumberNoError.
            t2 _ t2 + 1].
    ^ a

Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:

Code:

#SumOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/diffoflist.gif

Code:

('difference of items of %L' #r #DiffOf: 'list')

Method code:

Code:

DiffOf: t1 
    | t2 a |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    t2 _ 2.
    a _ (self getLine: 1 ofList: t1) asNumberNoError.
    (self lineCountOfList: t1)
        - 1
        timesRepeat: 
            [a _ a - (self getLine: t2 ofList: t1) asNumberNoError.
            t2 _ t2 + 1].
    ^ a

Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:

Code:

#DiffOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/prodoflist.gif

Code:

('product of items of %L' #r #ProdOf: 'list')

Method code:

Code:

ProdOf: t1 
    | t2 a |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    t2 _ 2.
    a _ (self getLine: 1 ofList: t1) asNumberNoError.
    (self lineCountOfList: t1)
        - 1
        timesRepeat: 
            [a _ a * (self getLine: t2 ofList: t1) asNumberNoError.
            t2 _ t2 + 1].
    ^ a

Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:

Code:

#ProdOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/quotoflist.gif

Code:

('quotient of items of %L' #r #QuotOf: 'list')

Method code:

Code:

QuotOf: t1 
    | t2 a |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    t2 _ 2.
    a _ (self getLine: 1 ofList: t1) asNumberNoError.
    (self lineCountOfList: t1)
        - 1
        timesRepeat: 
            [a _ a / (self getLine: t2 ofList: t1) asNumberNoError.
            t2 _ t2 + 1].
    ^ a

Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:

Code:

#QuotOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

Last edited by Greenatic (2011-07-30 17:14:59)

Offline

 

#1779 2011-07-30 18:56:49

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

Re: ITopic: Welcome to your local block library!

http://polyeztahpuppies.webs.com/fontnumber.gif

Code:

('font #%n' #r #FontNumber:)

Code:

FontNumber: t1 
    | t2 t3 |
    t1 isInf ifTrue: [^ nil].
    t1 isNaN ifTrue: [^ nil].
    t1 = t1 rounded ifFalse: [^ nil].
    t1 < 1 ifTrue: [^ nil].
    t2 _ UnicodePlugin getFontList.
    t2 size < t1 ifTrue: [^ nil].
    t3 _ 1.
    t2 do: 
        [:t4 | 
        t3 = t1 ifTrue: [^ t4].
        t3 _ t3 + 1]

@WhoeverDoesTheNextUpdate:  I pity you.  XD

Offline

 

#1780 2011-07-30 19:23:52

hello12345678910
Scratcher
Registered: 2009-07-11
Posts: 100+

Re: ITopic: Welcome to your local block library!

I noticed You had no explanation of "Instance" in the glossary. An instance is basically an object made from a class, but not the object itself. a little confusing


http://tinyurl.com/8yt32o9 http://tinyurl.com/6tgwp5r || Fish = F+I+S+H = 6+9+19+8 = 42<<The answer to Life, the Universe and Everything

Offline

 

#1781 2011-07-30 22:52:47

Skalled
Scratcher
Registered: 2010-04-17
Posts: 3

Re: ITopic: Welcome to your local block library!

The Show and hide cursor blocks don't work. I checked and the blockspec and Code are correctly copied. When the program gets to the block, If fill screen is turned off, it says: Message not Understood: showCursor/hideCursor. Can anyone help???

Last edited by Skalled (2011-07-30 22:57:03)

Offline

 

#1782 2011-07-31 00:20:05

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

Re: ITopic: Welcome to your local block library!

Greenatic wrote:

@WhoeverDoesTheNextUpdate:  I pity you.  XD

Well, I'll have to grab a few hours across a few days! XD
Or... hint, hint. (Librarians, what were you hired for?)

hello12345678910 wrote:

I noticed You had no explanation of "Instance" in the glossary. An instance is basically an object made from a class, but not the object itself. a little confusing

Instance: An object made from a class, but not the object itself.

Offline

 

#1783 2011-07-31 15:20:13

DovleacCreative
Scratcher
Registered: 2011-03-29
Posts: 4

Re: ITopic: Welcome to your local block library!

This is a text for my phanter aplication.

Offline

 

#1784 2011-07-31 22:36:24

Mcsugarface
Scratcher
Registered: 2009-11-16
Posts: 100+

Re: ITopic: Welcome to your local block library!

Made this block:
http://img829.imageshack.us/img829/7784/runwhile.gif
Here are the scripts:
http://img837.imageshack.us/img837/1717/runwhilescripts.gif

Simple.  tongue

Last edited by Mcsugarface (2011-07-31 22:42:27)


Hi! I'm http://blocks.scratchr.org/API.php?user=USERNAMEHERE&amp;action=onlineStatus&amp;type=text!
http://internetometer.com/imagesmall/11070.png

Offline

 

#1785 2011-07-31 22:43:28

Mcsugarface
Scratcher
Registered: 2009-11-16
Posts: 100+

Re: ITopic: Welcome to your local block library!

Or this:
http://img600.imageshack.us/img600/4540/runlwhilel.gif
The scripts:
http://img88.imageshack.us/img88/5262/runlwhilelscripts.gif


Hi! I'm http://blocks.scratchr.org/API.php?user=USERNAMEHERE&amp;action=onlineStatus&amp;type=text!
http://internetometer.com/imagesmall/11070.png

Offline

 

#1786 2011-08-01 03:50:54

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

Re: ITopic: Welcome to your local block library!

I reckon you should hire me as a librarian.  tongue   smile 
As I am online when almost no-one is, I can update the blocks and stuff, and save you guys some effort!  tongue   smile


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

Offline

 

#1787 2011-08-01 03:56:00

scratcher7_13
Scratcher
Registered: 2011-02-09
Posts: 1000+

Re: ITopic: Welcome to your local block library!

ssss wrote:

I reckon you should hire me as a librarian.  tongue   smile 
As I am online when almost no-one is, I can update the blocks and stuff, and save you guys some effort!  tongue   smile

Maybe you can hire us both?

Last edited by scratcher7_13 (2011-08-01 03:56:31)


♫ 90% of teens can't do math. If you are one of the 40% of teens who can, copy and paste this into your signature. ♫♪
http://dl.dropbox.com/u/6273449/BlockLibraryTitle.pnghttp://i.imgur.com/mr9Hf.gif

Offline

 

#1788 2011-08-01 07:32:35

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: ITopic: Welcome to your local block library!

Sidharth wrote:

I have a nice BYOB block that I think you do not already have:
http://i.imgur.com/FpG60.gif

.ysp file is here. (mediafire download link page)

that is on the byob tool sprite. It is called (sentance -> list [ ])


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#1789 2011-08-01 07:37:18

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: ITopic: Welcome to your local block library!

The 'most recent update' links the wrong post.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#1790 2011-08-02 10:01:20

jurk
Scratcher
Registered: 2010-05-06
Posts: 100+

Re: ITopic: Welcome to your local block library!

so cool  smile


http://dl.dropbox.com/u/54228408/cool.png

Offline

 

#1791 2011-08-02 13:11:11

Sidharth
Scratcher
Registered: 2007-12-14
Posts: 100+

Re: ITopic: Welcome to your local block library!

joefarebrother wrote:

Sidharth wrote:

I have a nice BYOB block that I think you do not already have:
http://i.imgur.com/FpG60.gif

.ysp file is here. (mediafire download link page)

that is on the byob tool sprite. It is called (sentance -> list [ ])

lol I think every block is in the tool sprite... I made that one by myself BTW. I have another one that can use a delimeter such as a comma or hyphen.


http://www.danasoft.com/citysign.jpg

Offline

 

#1792 2011-08-02 16:30:55

owetre18
Scratcher
Registered: 2009-07-01
Posts: 1000+

Re: ITopic: Welcome to your local block library!

The first post is all messed up. At least for me, it is.

Offline

 

#1793 2011-08-02 17:25:56

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

Re: ITopic: Welcome to your local block library!

So many new blocks!  (Sorry, Scimonster XD )

http://polyeztahpuppies.webs.com/additemstolist.gif

Code:

('add items %n to %n of %L to %L' #- #First:Last:From:To: '1' '3' 'list' 'list')

Method code:

Code:

First: t1 Last: t2 From: t3 To: t4 
    | t5 t6 |
    t1 isInf ifTrue: [^ self].
    t1 isNaN ifTrue: [^ self].
    t1 isNil ifTrue: [^ self].
    t2 isInf ifTrue: [^ self].
    t2 isNaN ifTrue: [^ self].
    t2 isNil ifTrue: [^ self].
    t1 = t1 rounded ifFalse: [^ self].
    t2 = t2 rounded ifFalse: [^ self].
    t1 < 1 ifTrue: [^ self].
    t2 < 1 ifTrue: [^ self].
    t1 > (self lineCountOfList: t3) ifTrue: [^ self].
    t2 > (self lineCountOfList: t3) ifTrue: [^ self].
    t5 _ t1.
    (t2 - t1) abs + 1
        timesRepeat: 
            [self append: (self getLine: t5 ofList: t3)
                toList: t4.
            t6 _ false.
            t2 > t1
                ifTrue: 
                    [t5 _ t5 + 1.
                    t6 _ true].
            t6 = false ifTrue: [t5 _ t5 - 1]]

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

Code:

#First:Last:From:To: = t4
        ifTrue: [t2 size >= 4
                ifTrue: 
                    [t2 at: 1 put: (t2 at: 1) localized.
                    t2 at: 2 put: (t2 at: 2) localized.
                    t2 at: 3 put: self defaultListName.
                    t2 at: 4 put: self defaultListName]].

http://polyeztahpuppies.webs.com/numbersort.gif

Code:

('sort items of %L by numerical value' #- #NumberSort: 'list')

Method code:

Code:

NumberSort: t1 
    | t2 t3 t4 t5 t6 |
    t2 _ #() asOrderedCollection.
    t3 _ #() asOrderedCollection.
    t4 _ #() asOrderedCollection.
    t6 _ #() asOrderedCollection.
    t5 _ 1.
    (self lineCountOfList: t1)
        timesRepeat: 
            [t2 add: (self getLine: t5 ofList: t1).
            t5 _ t5 + 1].
    t2 do: 
        [:t7 | 
        t3 add: t7 asNumberNoError.
        t7 asNumberNoError = 0 ifTrue: [t4 add: t7]].
    t3 _ t3 asArray sort.
    t3 _ t3 asOrderedCollection.
    t5 _ 1.
    t3 do: 
        [:t8 | 
        t8 = 0 ifFalse: [t6 add: t8].
        t8 = 0
            ifTrue: 
                [t6 add: (t4 at: t5).
                t5 _ t5 + 1]].
    self deleteLine: 'all' ofList: t1.
    t6 do: [:t9 | self append: t9 toList: t1]

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

Code:

#NumberSort: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/stringsort.gif

Code:

('sort items of %L by string value' #- #StringSort: 'list')

Method code:

Code:

SringSort: t1 
    | t2 t3 |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ self].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ self].
    t2 _ #() asOrderedCollection.
    t3 _ 1.
    (self lineCountOfList: t1)
        timesRepeat: 
            [t2 add: (self getLine: t3 ofList: t1).
            t3 _ t3 + 1].
    t2 _ t2 asArray sort.
    self deleteLine: 'all' ofList: t1.
    t2 do: [:t4 | self append: t4 toList: t1]

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

Code:

#StringSort: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/firstindex.gif

Code:

('first index of %s in %L' #r #IndexOf:List: '' 'list')

Method code:

Code:

IndexOf: t1 List: t2 
    | t3 |
    t3 _ 1.
    (self lineCountOfList: t2)
        timesRepeat: 
            [(self getLine: t3 ofList: t2)
                = t1 ifTrue: [^ t3].
            t3 _ t3 + 1].
    ^ 0

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

Code:

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

http://polyeztahpuppies.webs.com/timesappearsinlist.gif

Code:

('times %s appears in %L' #r #Times:List: '' 'list')

Method code:

Code:

Times: t1 List: t2 
    | t3 t4 |
    t3 _ 1.
    t4 _ 0.
    (self lineCountOfList: t2)
        timesRepeat: 
            [(self getLine: t3 ofList: t2)
                = t1 ifTrue: [t4 _ t4 + 1].
            t3 _ t3 + 1].
    ^ t4

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

Code:

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

http://polyeztahpuppies.webs.com/maxof.gif

Code:

('maximum value of %L' #r #MaxOf: 'list')

Method code:

Code:

MaxOf: t1 
    | max line |
    (self lineCountOfList: t1) asNumberNoError = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    max _ (self getLine: 1 ofList: t1) asNumberNoError.
    line _ 2.
    (self lineCountOfList: t1) asNumberNoError - 1
        timesRepeat: 
            [(self getLine: line ofList: t1) asNumberNoError > max ifTrue: [max _ (self getLine: line ofList: t1) asNumberNoError].
            line _ line + 1].
    ^ max

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

Code:

#MaxOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/minof.gif

Code:

('minimum value of %L' #r #MinOf: 'list')

Method code:

Code:

MinOf: t1 
    | min line |
    (self lineCountOfList: t1) asNumberNoError = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    min _ (self getLine: 1 ofList: t1) asNumberNoError.
    line _ 2.
    (self lineCountOfList: t1) asNumberNoError - 1
        timesRepeat: 
            [(self getLine: line ofList: t1) asNumberNoError < min ifTrue: [min _ (self getLine: line ofList: t1) asNumberNoError].
            line _ line + 1].
    ^ min

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

Code:

#MinOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/averageof.gif
*****Note:  This block requires a previously posted block, (sum of {list  v} ).******

Code:

('average/mean of values of %L' #r #AverageOf: 'list')

Method code:

Code:

AverageOf: t1 
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ self getLine: 1 ofList: t1].
    ^ (self SumOf: t1)
        / (self lineCountOfList: t1)

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

Code:

#AverageOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/rangeof.gif
*****Note: This block requires the (maximum value of {list  v} ) and (minimum value of {list  v} ) blocks.*****

Code:

('range of values of %L' #r #RangeOf: 'list')

Method code:

Code:

RangeOf: t1 
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ 0].
    ^ (self MaxOf: t1)
        - (self MinOf: t1)

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

Code:

#RangeOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/modesof.gif

Code:

('mode(s) of %L, spacer %s' #r #ModeOf:Spacer: 'list' ',')

Method code:

Code:

ModeOf: t1 Spacer: t2 
    | t3 t4 t5 t6 t7 |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ nil].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ nil].
    t3 _ #() asOrderedCollection.
    t4 _ #() asOrderedCollection.
    t5 _ 0.
    (self lineCountOfList: t1)
        timesRepeat: 
            [t6 _ 1.
            t7 _ false.
            t5 _ t5 + 1.
            (t3 includes: (self getLine: t5 ofList: t1) asNumberNoError)
                ifFalse: 
                    [t3 add: (self getLine: t5 ofList: t1) asNumberNoError.
                    t4 add: 1.
                    t7 _ true].
            t7 = false
                ifTrue: 
                    [[(t3 at: t6)
                        = (self getLine: t5 ofList: t1) asNumberNoError]
                        whileFalse: [t6 _ t6 + 1].
                    t4 _ t4 asArray.
                    t4 at: t6 put: (t4 at: t6)
                            + 1.
                    t4 _ t4 asOrderedCollection]].
    t5 _ 1.
    t6 _ 1.
    t4 size
        timesRepeat: 
            [(t4 at: t5)
                > t6 ifTrue: [t6 _ t4 at: t5].
            t5 _ t5 + 1].
    t6 = 1 ifTrue: [^ nil].
    t5 _ 1.
    t4 size
        timesRepeat: 
            [t7 _ false.
            (t4 at: t5)
                < t6
                ifTrue: 
                    [t3 removeAt: t5.
                    t4 removeAt: t5.
                    t7 _ true].
            t7 = false ifTrue: [t5 _ t5 + 1]].
    t3 size = 1 ifTrue: [^ t3 at: 1].
    t5 _ 2.
    t3 _ t3 asArray sort.
    t3 _ t3 asOrderedCollection.
    t6 _ (t3 at: 1) asString.
    t3 size - 1
        timesRepeat: 
            [t6 _ t6 , t2.
            t6 _ t6 , (t3 at: t5) asString.
            t5 _ t5 + 1].
    ^ t6

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

Code:

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

http://polyeztahpuppies.webs.com/medianof.gif

Code:

('median value of %L' #r #MedianOf: 'list')

Method code:

Code:

MedianOf: t1 
    | t2 t3 |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    t2 _ #() asOrderedCollection.
    t3 _ 1.
    (self lineCountOfList: t1)
        timesRepeat: 
            [t2 add: (self getLine: t3 ofList: t1) asNumberNoError.
            t3 _ t3 + 1].
    t2 _ t2 asArray sort.
    t2 _ t2 asOrderedCollection.
    [t2 size > 2]
        whileTrue: 
            [t2 removeAt: 1.
            t2 removeAt: t2 size].
    t2 size = 1 ifTrue: [^ t2 at: 1].
    ^ (t2 at: 1)
        + (t2 at: 2) / 2

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

Code:

#MedianOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

You actually read all that?  Wow. You must have way too much time on your hands.   wink

Offline

 

#1794 2011-08-02 17:33:34

rookwood101
Scratcher
Registered: 2011-07-29
Posts: 500+

Re: ITopic: Welcome to your local block library!

You actually read all that?  Wow. You must have way too much time on your hands.   wink

Yes, I do.


http://i.imgur.com/zeIZW.png

Offline

 

#1795 2011-08-02 18:05:05

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: ITopic: Welcome to your local block library!

Can I be a librarian for the block library for the BYOB section? here is all the blocks i have made

Last edited by flashgocrazy (2011-08-02 18:05:41)


◕‿◕

Offline

 

#1796 2011-08-02 18:23:23

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

Re: ITopic: Welcome to your local block library!

rookwood101 wrote:

You actually read all that?  Wow. You must have way too much time on your hands.   wink

Yes, I do.

You should read my earlier, even longer post.  I think it was on the last page, maybe the page before that.

Offline

 

#1797 2011-08-02 18:26:30

flashgocrazy
Scratcher
Registered: 2011-01-12
Posts: 500+

Re: ITopic: Welcome to your local block library!

some of my blocks:
http://i.imgur.com/cMWic.gif
http://i.imgur.com/89nJm.gif
download this block
and:
http://dl.dropbox.com/u/37086280/aaa.gif
http://db.tt/vJprJEF
download this block
also:
http://i.imgur.com/JVWfc.gif
http://i.imgur.com/O8mjj.gif
download this block
and:
http://i.imgur.com/XlaGN.gif
http://i.imgur.com/xoumh.gif
download this block
one of my very best:  smile
http://i.imgur.com/tVdLJ.gif
http://i.imgur.com/OknWx.gif
download this block
OMG!:
http://i.imgur.com/llFTi.gif
http://i.imgur.com/6EAKZ.gif
download this block
Requested from the block library:
http://i.imgur.com/jBnYM.gif
http://i.imgur.com/BrdKf.gif
download this block
NOTE: YOU NEED THE PAUSE SCRIPT BLOCK (SEE ABOVE) FOR THE BLOCK TO WORK (THE PAUSE SCRIPT BLOCK IS INCLUDED IN THE DOWNLOAD ABOVE.
Based on the panther block: {when camera open, do :}
http://i.imgur.com/S1OVA.gif
http://i.imgur.com/ESfwi.gif
download this block
based on the: [self] block in slash:
http://i.imgur.com/QiLlL.gif
http://i.imgur.com/GLw1W.gif
download this block

Last edited by flashgocrazy (2011-08-02 21:34:05)


◕‿◕

Offline

 

#1798 2011-08-02 21:37:25

thegombafan
New Scratcher
Registered: 2011-03-25
Posts: 20

Re: ITopic: Welcome to your local block library!

flashgocrazy wrote:

A lot of blocks

epic!! Can you make a few more blocks?

Offline

 

#1799 2011-08-03 01:02:37

LiquidMetal
Scratcher
Registered: 2011-06-15
Posts: 500+

Re: ITopic: Welcome to your local block library!

Greenatic wrote:

4 more blocks:

http://polyeztahpuppies.webs.com/sumoflist.gif

Code:

('sum of items of %L' #r #SumOf: 'list')

Method code:

Code:

SumOf: t1 
    | t2 a |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    t2 _ 2.
    a _ (self getLine: 1 ofList: t1) asNumberNoError.
    (self lineCountOfList: t1)
        - 1
        timesRepeat: 
            [a _ a + (self getLine: t2 ofList: t1) asNumberNoError.
            t2 _ t2 + 1].
    ^ a

Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:

Code:

#SumOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/diffoflist.gif

Code:

('difference of items of %L' #r #DiffOf: 'list')

Method code:

Code:

DiffOf: t1 
    | t2 a |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    t2 _ 2.
    a _ (self getLine: 1 ofList: t1) asNumberNoError.
    (self lineCountOfList: t1)
        - 1
        timesRepeat: 
            [a _ a - (self getLine: t2 ofList: t1) asNumberNoError.
            t2 _ t2 + 1].
    ^ a

Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:

Code:

#DiffOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/prodoflist.gif

Code:

('product of items of %L' #r #ProdOf: 'list')

Method code:

Code:

ProdOf: t1 
    | t2 a |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    t2 _ 2.
    a _ (self getLine: 1 ofList: t1) asNumberNoError.
    (self lineCountOfList: t1)
        - 1
        timesRepeat: 
            [a _ a * (self getLine: t2 ofList: t1) asNumberNoError.
            t2 _ t2 + 1].
    ^ a

Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:

Code:

#ProdOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/quotoflist.gif

Code:

('quotient of items of %L' #r #QuotOf: 'list')

Method code:

Code:

QuotOf: t1 
    | t2 a |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    t2 _ 2.
    a _ (self getLine: 1 ofList: t1) asNumberNoError.
    (self lineCountOfList: t1)
        - 1
        timesRepeat: 
            [a _ a / (self getLine: t2 ofList: t1) asNumberNoError.
            t2 _ t2 + 1].
    ^ a

Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:

Code:

#QuotOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

Why not have a dropdown that you can select from either sum, difference, product, or quotient?

Offline

 

#1800 2011-08-03 04:28:38

rookwood101
Scratcher
Registered: 2011-07-29
Posts: 500+

Re: ITopic: Welcome to your local block library!

LiquidMetal wrote:

Greenatic wrote:

4 more blocks:

http://polyeztahpuppies.webs.com/sumoflist.gif

Code:

('sum of items of %L' #r #SumOf: 'list')

Method code:

Code:

SumOf: t1 
    | t2 a |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    t2 _ 2.
    a _ (self getLine: 1 ofList: t1) asNumberNoError.
    (self lineCountOfList: t1)
        - 1
        timesRepeat: 
            [a _ a + (self getLine: t2 ofList: t1) asNumberNoError.
            t2 _ t2 + 1].
    ^ a

Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:

Code:

#SumOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/diffoflist.gif

Code:

('difference of items of %L' #r #DiffOf: 'list')

Method code:

Code:

DiffOf: t1 
    | t2 a |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    t2 _ 2.
    a _ (self getLine: 1 ofList: t1) asNumberNoError.
    (self lineCountOfList: t1)
        - 1
        timesRepeat: 
            [a _ a - (self getLine: t2 ofList: t1) asNumberNoError.
            t2 _ t2 + 1].
    ^ a

Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:

Code:

#DiffOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/prodoflist.gif

Code:

('product of items of %L' #r #ProdOf: 'list')

Method code:

Code:

ProdOf: t1 
    | t2 a |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    t2 _ 2.
    a _ (self getLine: 1 ofList: t1) asNumberNoError.
    (self lineCountOfList: t1)
        - 1
        timesRepeat: 
            [a _ a * (self getLine: t2 ofList: t1) asNumberNoError.
            t2 _ t2 + 1].
    ^ a

Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:

Code:

#ProdOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

http://polyeztahpuppies.webs.com/quotoflist.gif

Code:

('quotient of items of %L' #r #QuotOf: 'list')

Method code:

Code:

QuotOf: t1 
    | t2 a |
    (self lineCountOfList: t1)
        = 0 ifTrue: [^ 0].
    (self lineCountOfList: t1)
        = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError].
    t2 _ 2.
    a _ (self getLine: 1 ofList: t1) asNumberNoError.
    (self lineCountOfList: t1)
        - 1
        timesRepeat: 
            [a _ a / (self getLine: t2 ofList: t1) asNumberNoError.
            t2 _ t2 + 1].
    ^ a

Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:

Code:

#QuotOf: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

Why not have a dropdown that you can select from either sum, difference, product, or quotient?

I would say the same with mean, median and mode, as they are all types of averages.


http://i.imgur.com/zeIZW.png

Offline

 

Board footer