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 -240 )y 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 -240 )y 0)><pen down><end>>[/blocks]use new lines between blocks like this:
[blocks]<when green flag clicked>
< delete (all) of [amp]>
<go to x -240 )y 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 theCode:
[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
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 -240 )y 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 -240 )y 0)><pen down><end>>[/blocks]use new lines between blocks like this:
[blocks]<when green flag clicked>
< delete (all) of [amp]>
<go to x -240 )y 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 theCode:
[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.
Offline
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)
Offline
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
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...
Offline
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.
Offline
I did them in chronological order, starting with the oldest. I had to start on page 72.
Offline
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...
Offline
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)
Offline
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
Offline
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
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
Anyone want me to tell how to make a bock telling if your running windows or MacOSX?
Offline
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.
Offline
Try
isMac ^SystemDictionary isMacOSX
Not sure if it works.
Offline
sparks wrote:
Pecola1 wrote:
Try
Code:
isMac ^SystemDictionary isMacOSXNot 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.
Offline
SpaceManMike wrote:
Anyone want me to tell how to make a bock telling if your running windows or MacOSX?
ReportOS FileDirectory default fileExists: 'Scratch.exe' ifTrue:[^ 'Windows']. FileDirectory default fileExists: 'Scratch.app' ifTrue:[^ 'Mac']. ^ 'Linux'
Offline
sparks wrote:
MathWizz wrote:
Code:
Smalltalk platformNameInteresting... 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 isMacOSXNot 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.
isMacOSX is an instance method, not a class one. Use:
^ (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.
Last edited by Greenatic (2011-12-27 16:28:34)
Offline
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)
Offline
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)
Offline
joefarebrother wrote:
Splodgey wrote:
Greenatic wrote:
No, he was referring to lu9.
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 tagcode:
Code:
the code in a code tagFor BYOB:
image of block (with no inputs)
image of the scripts
How do I add an image?
Offline