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

#2451 2011-12-18 03:19:54

ianidani
New Scratcher
Registered: 2011-12-17
Posts: 3

Re: ITopic: Welcome to your local block library!

joefarebrother wrote:

ianidani wrote:

Here is a sound amplitude recorder and writer.(Sorry, it cannot replay the music)
[blocks]<when green flag clicked>< delete (all) of [amp]><go to x sad  -240 )y sad 0) <pen up><clear><set pen color to( 0)<point in direction( 0)<pen down><recorddb>

recorddb is:
<<forever><<repeat( 480)<set y to( <loudness>)<change x by(1)<add <loudness> to [amp]><end>>
<clear><pen up><go to x sad -240 )y sad  0)><pen down><end>>[/blocks]

use new lines between blocks like this:

[blocks]<when green flag clicked>
< delete (all) of [amp]>
<go to x sad  -240 )y sad 0)
<pen up>
<clear><set pen color to( 0)
<point in direction( 0)
<pen down>
<recorddb>

recorddb is:
<<forever>
<<repeat( 480)
<set y to( <loudness>)
<change x by(1)
<add <loudness> to [amp]>
<end>> [/blocks]




Oh, and please remember the

Code:

[blocks][/blocks]

tage when you use the blocks.

thanks. i am a new stracher and i do not know how to put this blocks.

Offline

 

#2452 2011-12-18 03:44:19

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

Re: ITopic: Welcome to your local block library!

ianidani wrote:

joefarebrother wrote:

ianidani wrote:

Here is a sound amplitude recorder and writer.(Sorry, it cannot replay the music)
[blocks]<when green flag clicked>< delete (all) of [amp]><go to x sad  -240 )y sad 0) <pen up><clear><set pen color to( 0)<point in direction( 0)<pen down><recorddb>

recorddb is:
<<forever><<repeat( 480)<set y to( <loudness>)<change x by(1)<add <loudness> to [amp]><end>>
<clear><pen up><go to x sad -240 )y sad  0)><pen down><end>>[/blocks]

use new lines between blocks like this:

[blocks]<when green flag clicked>
< delete (all) of [amp]>
<go to x sad  -240 )y sad 0)
<pen up>
<clear><set pen color to( 0)
<point in direction( 0)
<pen down>
<recorddb>

recorddb is:
<<forever>
<<repeat( 480)
<set y to( <loudness>)
<change x by(1)
<add <loudness> to [amp]>
<end>> [/blocks]




Oh, and please remember the

Code:

[blocks][/blocks]

tage when you use the blocks.

thanks. i am a new stracher and i do not know how to put this blocks.

A better way to display blocks if to make the script in the scratch (or BYOB or panther) program and right click and select "save picture of scripts". Then put it on some image hosting site (like tinypic) and put it in an [img] tag in your post. Since you are new scratcher though, simply post the url of the image and ask someone else to add the tags.


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

 

#2453 2011-12-18 14:41:26

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

Re: ITopic: Welcome to your local block library!

Of the clipboard blocks, one is incorrect, one's name is misleading, and both should be in sensing.
The "min x", "max x", etc. blocks are incorrect and should be in motion under the names "left", "left x", or "left x position", etc.
There are two identical Scratch Looks blocks, "name of costume %n" and "name of costume #%n".
Greenatic forgot to include my panther auto-updating block in the library update.

Scratch Blocks
('clipboard contents'                r    clipboard) (tested, watchable)

clipboard
    "Answer the clipboard contents as a UTF8 string."
    ^ ScratchTranslator unicodeClipboard asUTF8

('copy %s to clipboard'                -    clipboard:) (tested)

clipboard: aString
    "Copy aString to the clipboard."
    ^ ScratchTranslator unicodeClipboardPut: aString

('left x'                            r    refLeft) (tested, watchable)

refLeft
    ^ (self referenceFromPoint: bounds origin) x

('right x'                        r    refRight) (tested, watchable)

refRight
    ^ (self referenceFromPoint: bounds corner) x

('top y'                            r    refTop) (tested, watchable)

refTop
    ^ (self referenceFromPoint: bounds origin) y

('bottom y'                        r    refBottom) (tested, watchable)

refBottom
    ^ (self referenceFromPoint: bounds corner) y

Helper method:

referenceFromPoint: aPoint
    | p s |
    p _ aPoint - ScratchOrigin.

    "adjust when in Hand in quartersize mode:"
    ((owner isKindOf: HandMorph) and:
     [((s _ owner formerOwner) isKindOf: ScratchStageMorph) and:
     [s isQuarterSize]]) ifTrue: [
        "Note: this is not quite right when rotation center is offset"
        p _ (p * 2) + (240@180)].

    ^ p x @ p y negated

('letter %n of the alphabet' r alphabetLetter:) (tested, rewritten)

alphabetLetter: letterNum
    ^ (letterNum between: 1 and: 26) ifTrue: [(($a to: $z) at: letterNum) asString] ifFalse: ['']

('- %n' r negate: -) (tested, rewritten)

negate: aNumber
    ^ aNumber negated

('letters %n to %n of %s'            r    substring:to:of: 1 5 'hello world') (tested, rewritten)

substring: start to: end of: aString
    | s e |
    s := start rounded.
    e := end rounded.
    s > aString size ifTrue: [^ ''].
    (e - s) < 0 ifTrue: [^ ''].
    e := e min: aString size.
    s := s max: 1.
    ^ aString asString copyFrom: s to: e

('first %n letters of %s'            r    first:of: 5 'hello world') (tested, rewritten)

first: aNumber of: aString
    | n |
    n := aNumber rounded.
    n <= 0 ifTrue: [^ ''].
    n >= aString size ifTrue: [^ aString].
    ^ aString copyFrom: 1 to: n.

('last %n letters of %s'            r    last:of: 5 'hello world')

last: aNumber of: aString
    | n |
    n := aNumber rounded.
    n <= 0 ifTrue: [^ ''].
    n >= aString size ifTrue: [^ aString].
    ^ aString copyFrom: aString size - n + 1 to: aString size.

Panther Blocks
update from [] with version [] (tested)
This block performs an automatic update from the URL specified. The URL should point to a directory containing (at least) a file named version.txt, and a file named <first line of version.txt>.pt (the most recent version of the project). The second argument to the block specifies the current version of the project. If the user is using an outdated project (the version is not the same as the first line of version.txt), he/she is asked if he/she wants to download the new version. If so, the new version is downloaded, opened, and run.

(-) update from $String$ with version $String$

"Usage: provide a directory URL with version.txt and (first line of version.txt).pt"
| version frame dir name stream |

(t1 endsWith: '/') ifFalse: [t1 := t1, '/'].
frame := ScratchFrameMorph allInstances first.
version := (HTTPSocket httpGet: t1, 'version.txt') contents lines first.
version = t2 ifTrue: [^ self].

(DialogBoxMorph ask: 'A new version (', version, ') is available. Would you like to download it?') ifFalse: [^ self].

name := frame projectName, '.pt'.

(dir := frame projectDirectory) deleteFileNamed: name.

stream := (dir newFileNamed: version, '.pt').
stream reset.
stream nextPutAll: (HTTPSocket httpGet: t1, version, '.pt') contents.

frame openScratchProjectNamed: dir pathName, dir slash, version, '.pt'; shoutGo.

(r) project location (tested, watchable)

"Answer the path to the currently open Panther project, or an empty string."
    | frame |
    frame := ScratchFrameMorph allInstances first.
    ^ frame projectName isEmpty ifTrue: [''] ifFalse: [frame projectDirectory pathName, frame projectDirectory slash, frame projectName, '.pt']

(-) text $String$ color $Color$ size $Number$ font $String$ (tested)

| font csize cnv cst |
font := StrikeFont fontName: t4 size: t3.
csize := (font widthOfString: t1)@(font height).
cnv := FormCanvas on: (Form extent: csize depth: 8).
cnv text: t1 at: 0@0 font: font color: t2.
cst := ImageMedia new form: cnv form; mediaName: (self unusedMediaNameFromBaseName: costume mediaName).
media add: cst.
self lookLike: cst mediaName

Last edited by nXIII (2011-12-18 14:42:12)


nXIII

Offline

 

#2454 2011-12-18 20:06:49

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

Re: ITopic: Welcome to your local block library!

nXIII wrote:

Greenatic forgot to include my panther auto-updating block in the library update.

I did not forget your block.  Rather, Sparks is the only one who does Panther updates, and he's on vacation until the 23rd.

Offline

 

#2455 2011-12-18 20:21:19

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

Re: ITopic: Welcome to your local block library!

Greenatic wrote:

nXIII wrote:

Greenatic forgot to include my panther auto-updating block in the library update.

I did not forget your block.  Rather, Sparks is the only one who does Panther updates, and he's on vacation until the 23rd.

Ive done a panther one...


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

 

#2456 2011-12-18 20:49:32

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

Re: ITopic: Welcome to your local block library!

Greenatic wrote:

nXIII wrote:

Greenatic forgot to include my panther auto-updating block in the library update.

I did not forget your block.  Rather, Sparks is the only one who does Panther updates, and he's on vacation until the 23rd.

I think you forgot these, (and this).


nXIII

Offline

 

#2457 2011-12-18 21:54:11

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

Re: ITopic: Welcome to your local block library!

nXIII wrote:

Greenatic wrote:

nXIII wrote:

Greenatic forgot to include my panther auto-updating block in the library update.

I did not forget your block.  Rather, Sparks is the only one who does Panther updates, and he's on vacation until the 23rd.

I think you forgot these, (and this).

I did them in chronological order, starting with the oldest.  I had to start on page 72.   tongue

Offline

 

#2458 2011-12-19 12:25:32

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

Re: ITopic: Welcome to your local block library!

nXIII wrote:

Of the clipboard blocks, one is incorrect, one's name is misleading, and both should be in sensing.
The "min x", "max x", etc. blocks are incorrect and should be in motion under the names "left", "left x", or "left x position", etc.
There are two identical Scratch Looks blocks, "name of costume %n" and "name of costume #%n".
Greenatic forgot to include my panther auto-updating block in the library update.

A lot of those have been shared I believe...


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

 

#2459 2011-12-19 12:26:56

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

Re: ITopic: Welcome to your local block library!

Pecola1 wrote:

nXIII wrote:

Of the clipboard blocks, one is incorrect, one's name is misleading, and both should be in sensing.
The "min x", "max x", etc. blocks are incorrect and should be in motion under the names "left", "left x", or "left x position", etc.
There are two identical Scratch Looks blocks, "name of costume %n" and "name of costume #%n".
Greenatic forgot to include my panther auto-updating block in the library update.

A lot of those have been shared I believe...

Hence, "(rewritten)"

Last edited by nXIII (2011-12-19 12:27:21)


nXIII

Offline

 

#2460 2011-12-19 12:41:23

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

Re: ITopic: Welcome to your local block library!

nXIII wrote:

Pecola1 wrote:

nXIII wrote:

Of the clipboard blocks, one is incorrect, one's name is misleading, and both should be in sensing.
The "min x", "max x", etc. blocks are incorrect and should be in motion under the names "left", "left x", or "left x position", etc.
There are two identical Scratch Looks blocks, "name of costume %n" and "name of costume #%n".
Greenatic forgot to include my panther auto-updating block in the library update.

A lot of those have been shared I believe...

Hence, "(rewritten)"

XD I didn't read it all cuz its so long... XD

@Sparks what do we do when someone rewrites a script? Ban them? jk XD


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

 

#2461 2011-12-21 04:11:52

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

Re: ITopic: Welcome to your local block library!

Greenatic wrote:

@All librarians:  I post all my block images on an old Webs account, but I would prefer, for the sake of organization, that I keep that for only my block images (I use this as a way to go back and figure out what blocks I made).  Some people (no names to be mentioned!) didn't upload pictures, and I was never granted access to the weebly (I think).  Could someone please upload and post links for the following blockspecs:

('%n is even?' #b #even:)
('a:%n b:%n c:%n is Pythagorean triplet?' #b #py: 3 4 5 th:ag:)
('if x: %n y: %n , go to x: %n y: %n' #- #ifx:y:gox:y: 0 0 10 10)

Um. I'm pretty sure the Weebly account has the same username and password as the Scratch account.
I'm not sure because I haven't logged in in months. XD

Last edited by scimonster (2011-12-21 04:12:31)

Offline

 

#2462 2011-12-21 14:43:56

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

Re: ITopic: Welcome to your local block library!

scimonster wrote:

Greenatic wrote:

@All librarians:  I post all my block images on an old Webs account, but I would prefer, for the sake of organization, that I keep that for only my block images (I use this as a way to go back and figure out what blocks I made).  Some people (no names to be mentioned!) didn't upload pictures, and I was never granted access to the weebly (I think).  Could someone please upload and post links for the following blockspecs:

('%n is even?' #b #even:)
('a:%n b:%n c:%n is Pythagorean triplet?' #b #py: 3 4 5 th:ag:)
('if x: %n y: %n , go to x: %n y: %n' #- #ifx:y:gox:y: 0 0 10 10)

Um. I'm pretty sure the Weebly account has the same username and password as the Scratch account.
I'm not sure because I haven't logged in in months. XD

Lol, should have tried that.  XD

Offline

 

#2463 2011-12-26 08:03:31

SpaceManMike
Scratcher
Registered: 2008-02-09
Posts: 100+

Re: ITopic: Welcome to your local block library!

Anyone want me to tell how to make a bock telling if your running windows or MacOSX?


http://26.media.tumblr.com/tumblr_lvdp6tYTlp1qkvzkho1_500.png

Offline

 

#2464 2011-12-26 19:42:43

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

Re: ITopic: Welcome to your local block library!

SpaceManMike wrote:

Anyone want me to tell how to make a bock telling if your running windows or MacOSX?

I can make that. It'll be a few seconds.


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

 

#2465 2011-12-26 19:48:46

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

Re: ITopic: Welcome to your local block library!

Try

Code:

isMac
^SystemDictionary isMacOSX

Not sure if it works.


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

 

#2466 2011-12-27 07:35:13

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

Re: ITopic: Welcome to your local block library!

Pecola1 wrote:

Try

Code:

isMac
^SystemDictionary isMacOSX

Not sure if it works.

Reports ERROR for me (Windows 7 64bit)


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

Offline

 

#2467 2011-12-27 09:31:32

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

Re: ITopic: Welcome to your local block library!

sparks wrote:

Pecola1 wrote:

Try

Code:

isMac
^SystemDictionary isMacOSX

Not sure if it works.

Reports ERROR for me (Windows 7 64bit)

Then I guess it works. Right? XD Actually maybe it does... maybe it reports error if your not mac... just tried it and it did error. I use win 7 too.  hmm


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

 

#2468 2011-12-27 15:11:03

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

Re: ITopic: Welcome to your local block library!

SpaceManMike wrote:

Anyone want me to tell how to make a bock telling if your running windows or MacOSX?

Code:

ReportOS
FileDirectory default fileExists: 'Scratch.exe' ifTrue:[^ 'Windows'].
FileDirectory default fileExists: 'Scratch.app' ifTrue:[^ 'Mac'].
^ 'Linux'

Offline

 

#2469 2011-12-27 15:37:46

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

Re: ITopic: Welcome to your local block library!

Code:

Smalltalk platformName

Last edited by MathWizz (2011-12-27 15:38:07)


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

Offline

 

#2470 2011-12-27 16:03:38

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

Re: ITopic: Welcome to your local block library!

MathWizz wrote:

Code:

Smalltalk platformName

Interesting... that reports "Win32" to me, although I'm on Windows 7 64bit...


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

Offline

 

#2471 2011-12-27 16:17:23

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

Re: ITopic: Welcome to your local block library!

sparks wrote:

MathWizz wrote:

Code:

Smalltalk platformName

Interesting... that reports "Win32" to me, although I'm on Windows 7 64bit...

After some code digging, it appears that 'Win32' represents any Windows OS...

Pecola1 wrote:

sparks wrote:

Pecola1 wrote:

Try

Code:

isMac
^SystemDictionary isMacOSX

Not sure if it works.

Reports ERROR for me (Windows 7 64bit)

Then I guess it works. Right? XD Actually maybe it does... maybe it reports error if your not mac... just tried it and it did error. I use win 7 too.  hmm

isMacOSX is an instance method, not a class one.  Use:

Code:

 ^ (SystemDictionary new) isMacOSX

I like my version better because it supports Linux.  However, in addition to isMacOSX, there are also isWindows and isUnix methods. 

There are also useUpMemory, useUpMemoryWithArrays, useUpMemoryWithContexts, and useUpMemoryWithTinyObjects methods that all use different ways to freeze Scratch.  Interesting.   hmm

Last edited by Greenatic (2011-12-27 16:28:34)

Offline

 

#2472 2011-12-27 19:17:46

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

Re: ITopic: Welcome to your local block library!

OS blocks! (these should go in sensing)

('operating system' r platformName) (tested)

platformName
    ^ Smalltalk platformName

('operating system version' r osVersion) (tested)

osVersion
    ^ Smalltalk osVersion

('Mac OS X?' b isMacOSX) (tested)

isMacOSX
    ^ Smalltalk isMaxOSX

('Unix?' b isUnix) (tested)

isUnix
    ^ Smalltalk isUnix

('Windows?' b isWindows) (tested)

isWindows
    ^ Smalltalk isWindows

EDIT: Tested them all!

Last edited by nXIII (2011-12-27 21:57:55)


nXIII

Offline

 

#2473 2011-12-27 21:57:26

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

Re: ITopic: Welcome to your local block library!

Variable Blocks!

('make %s' - addVariable:) (tested)
('make %s with value %s' - addVariable:value:) (tested)
('delete %s' - deleteVariable:) (tested)

('set layout of %v to %V' - setLayoutOfVar:to:) (tested)

setLayoutOfVar: varName to: layout
    | symbol b w frame stage |
    symbol := layout asSymbol.
    frame := self ownerThatIsA: ScratchFrameMorph.
    frame ifNil: [
        (w := self ownerThatIsA: OffscreenWorldMorph) ifNil: [^ self].
        frame := w frame].
    (self varNames includes: varName) ifFalse: [
        stage := frame workPane.
        (stage varNames includes: varName) ifTrue: [^ stage setLayoutOfVar: varName to: layout]].
   
    b := VariableBlockMorph new commandSpec: varName; receiver: self blockReceiver.
    w := frame watcherForBlock: b.
    w ifNotNil: [w layoutStyle: symbol]

CommandBlockMorph >> uncoloredArgMorphFor: specString (add before final return)
    $V = code ifTrue: [^ ChoiceOrExpressionArgMorph new options: #(normal slider large)].

('set slider range of %v to %n..%n' - setSliderRange:min:max:) (tested)

setSliderRange: varName min: min max: max
    | b w frame stage slider sliderMin sliderMax |
    frame := self ownerThatIsA: ScratchFrameMorph.
    frame ifNil: [
        (w := self ownerThatIsA: OffscreenWorldMorph) ifNil: [^ self].
        frame := w frame].
    (self varNames includes: varName) ifFalse: [
        stage := frame workPane.
        (stage varNames includes: varName) ifTrue: [^ stage setSliderRange: varName min: min max: max]].
   
    b := VariableBlockMorph new commandSpec: varName; receiver: self blockReceiver.
    w := frame watcherForBlock: b.
    w ifNotNil: [
        slider := w instVarNamed: #scratchSlider.
        slider ifNil: [^ self].
        sliderMin := min asNumberNoError.
        sliderMax := max asNumberNoError.
        slider minVal: sliderMin;
            maxVal: sliderMax;
            truncate: (sliderMin isInteger & sliderMax isInteger);
            updateSliderPosition].

Last edited by nXIII (2011-12-28 14:32:29)


nXIII

Offline

 

#2474 2011-12-28 07:08:52

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

Re: ITopic: Welcome to your local block library!

These looks pretty good, thanks nXIII  smile


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

Offline

 

#2475 2011-12-28 10:45:32

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: ITopic: Welcome to your local block library!

joefarebrother wrote:

Splodgey wrote:

Greenatic wrote:


No, he was referring to lu9.   tongue

700TH POST!!!

DID I submit it correctly? If not how do I submit it correctly?

For scratch and panther. use this syntax:

image of block (with no inputs) - if you are a new scratcher, just post the url and ask someone else to add the [img] tags

blockspec:

Code:

 the blockspec in a code tag

code:

Code:

 the code in a code tag

For BYOB:

image of block (with no inputs)
image of the scripts

How do I add an image?

Offline

 

Board footer