sparks wrote:
you know what this thread needs? collapsable sections! That would make this so much neater! Oh well, I'm still thankful for all the things bb code does let me do!
In the bbcode list, there are instructions for creating email links even though you're not allowed to do emails in the forums! :O
What I did (in the Prism forums while writing a programming language manual....) was post successive posts, get their links, then make a "table of contents" on the first post with links to all the other ones. Sadly, you can't do that without closing the thread to everyone but yourself.
EDIT: Oh, a suggestion for the ()^() block: use (10 ^ (log(base) * exponent)) instead.
Last edited by nXIII (2010-09-14 17:52:23)
Offline
Woo, ITopic'd!
Offline
Jwosty wrote:
There's a much easier way to code the "pick random of ..." block:
http://i52.tinypic.com/21lj3ol.gif
Any tends to glitch.
I used that so that it picks something random. It wont seed based on milliseconds. Or the glitchy Any.
Offline
nXIII wrote:
sparks wrote:
you know what this thread needs? collapsable sections! That would make this so much neater! Oh well, I'm still thankful for all the things bb code does let me do!
In the bbcode list, there are instructions for creating email links even though you're not allowed to do emails in the forums!What I did (in the Prism forums while writing a programming language manual....) was post successive posts, get their links, then make a "table of contents" on the first post with links to all the other ones. Sadly, you can't do that without closing the thread to everyone but yourself.
EDIT: Oh, a suggestion for the ()^() block: use (10 ^ (log(base) * exponent)) instead.
technically I suppose I could randomly start posting different sections now, and link to them in the first post...
Offline
sparks wrote:
nXIII wrote:
sparks wrote:
you know what this thread needs? collapsable sections! That would make this so much neater! Oh well, I'm still thankful for all the things bb code does let me do!
In the bbcode list, there are instructions for creating email links even though you're not allowed to do emails in the forums!What I did (in the Prism forums while writing a programming language manual....) was post successive posts, get their links, then make a "table of contents" on the first post with links to all the other ones. Sadly, you can't do that without closing the thread to everyone but yourself.
EDIT: Oh, a suggestion for the ()^() block: use (10 ^ (log(base) * exponent)) instead.technically I suppose I could randomly start posting different sections now, and link to them in the first post...
Yea, just put a "Back to Contents" link at the bottom of each "chapter"
Offline
Glossary
Report: The answer to a block. the (X postion) block reports the x position.
Argument: any space where you can type, drop other blocks or select from a dropdown is called an argument. When people talk about a block, they use a $ symbol o indicate where the argument is (panther blocks) or a % symbol for scratch blocks.
Panther says: "if $Boolean$ then $String$ else $String$"
Scratch says: "if %b then %s else %s"
Boolean: The pointy shaped block that reports true or false when clicked.
String: is a white, rectangular area in a block where you can type text. (such as the "say [hello]" block.
Number (argument): a white, oval shaped area in a block where you can type numbers and commas/periods (,/.) but no other keyboard symbols. (such as the (( )+( )) block.
Run: this basically means the block or script is doing what it does. There will be a white line around the blocks when they are running.
Instance: commonly misunderstood word... not sure what it means myself, please do post a lamen's terms explaination for this!
^ back to Contents
Last edited by sparks (2010-11-01 15:35:35)
Offline
How to add one of these blocks to Scratch:
I suggest visiting this excellent forum page. It has a full explanation from Billyedward. You can also look at this detailed explaination on the layout of blockspecs by ScratchReallyRocks.
Choose a block type to view, or scroll down this page to see more!
Motion
Control
Looks
Sensing
Sound
Operators
Pen
Variables
home
Last edited by sparks (2011-01-03 13:41:55)
Offline
Motion
Shared by MarioBlender
Blockspec:
'make %m move %n steps' #- #move:forward:
Code:
move: sprite forward: distance
sprite forward: distance
What this block does:
Lets a sprite move another sprite without having to use a broadcast!
Shared by MathWizz
Blockspec:
('if touching %m bounce' #- #bounceOffSprite:)
Code:
bounceOffSprite: aName
| sprite oldDir |
sprite _ self coerceSpriteArg: aName.
(self touching: sprite)
ifFalse: [^ self].
oldDir _ self heading.
self pointTowards: sprite.
self turnRight: self heading - oldDir + 180.
[self touching: sprite]
whileTrue: [self forward: 1]
What this block does:
Causes the sprite to bounce of a selected sprite if touching it. (assumes the sprite is a circle).
Shared by Pecola1
Blockspec:
('set rotation style to %r' #- #rotationStyleChange:)
Scratch-objects> ScratchSpriteMorph>motion ops
rotationStyleChange: t1
self rotationStyle: t1
Scratch objects> ScratchSpriteMorph>motion ops
rotationStyleChanger
^ #('normal' 'leftRight' 'none' )
Scratch-Blocks> CommandBlockMorph>> -- all -- > uncoleredArgMorphFor:
add the strip...
$r = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #rotationStyleChanger;
choice: 'normal'].
What this block does:
Allows you to change the rotation style of a sprite.
Shared by Pecola1
Blockspec:
('rotation style' #r #rotationStyle)
Code:
rotationStyle
^ rotationStyle
What this block does:
Reports a sprite's rotation style.
Shared by StrykerV, improved by Pecola1
Blockspec:
('point at x:%n y:%n' #- #pointToX:y:)
Code:
No code needed
What this block does:
Points the sprite at the specified region of the stage.
Shared by Hardmath123
Blockspec:
('go to random x-y position' #- #randxypos)
Code:
randxypos self gotoX: (self randomFrom: -240 to: 240) y: (self randomFrom: -180 to: 180)
What this block does:
Moves the sprite to a random space on the stage.
^ Back to Scratch Blocks
^ Back to Contents
Last edited by sparks (2011-01-13 15:22:39)
Offline
Control
Shared by Sparks
blockspec:
'open camera window' #- #takePhoto
no code needed
What it does:
Opens the webcam control window and lets you take photos.
Shared by Billybob-Mario
blockspec:
'save project' #- #saveProj
code:
saveProj
| t1 |
t1 _ self ownerThatIsA: ScratchFrameMorph.
t1 saveScratchProject
What it does:
opens the save project as dialog and lets you save it!
Shared by bbbeb
blockspec:
'Press Green Flag' - pressGreenFlag
code
pressGreenFlag
#pressGreenFlagButton
What it does:
triggers all scripts starting with a "when green flag clicked" hat.
Shared by zorket
blockspec:
('go to scratch website...' #- #link)
code
link
Cursor wait showWhile: [ScratchPlugin primOpenURL: 'http://scratch.mit.edu/']
What it does:
Opens the Scratch homepage!
Shared by zorket (made by rubiks_cube_guy238)
blockspec:
(I recieve %e' #b #seesBroadcast)
code
seesBroadcast: t1
| t2 |
t2 _ ScratchEvent allInstances.
t2
reverseDo:
[:t3 |
t3 name = t1 ifTrue: [^ true].
nil].
^ false
What it does:
lets you test to see if a broadcast is being sent. Much sought after and requested.
Shared by midnightleopard
blockspec:
('%j %s' #- #doThis:on:)
code (place under sensing ops)
doThis: t1 on: t2
| engines l |
'google' = t1 ifTrue: [ScratchPlugin primOpenURL: 'http://www.google.com/#sclient=psy&hl=en&q=' , t2 , '&aq=f&aqi=g5&aql=&oq=&gs_rfai=&pbx=1&fp=ab5cdb1806fef4aa&safe=activet1'].
'yahoo' = t1 ifTrue: [ScratchPlugin primOpenURL: 'http://search.yahoo.com/search;_ylt=Aj.OqjGVrkBmY6mZqA_PSu.bvZx4?p=' , t2 , '&toggle=1&cop=mss&ei=UTF-8&fr=yfp-t-701'].
'scratch.mit.edu/' = t1 ifTrue: [ScratchPlugin primOpenURL: 'http://scratch.mit.edu/' , t2].
'search scratch for' = t1 ifTrue: [ScratchPlugin primOpenURL: 'http://scratch.mit.edu/pages/results?cx=010101365770046705949:gg_q9cry0mq&cof=FORID:11&q=' , t2 , '&safe=active&sa=search'].
'IMDB' = t1 ifTrue: [ScratchPlugin primOpenURL: 'http://www.imdb.com/find?s=all&q=' , t2].
'load' = t1 ifTrue: [^ 0].
^ 0
Code (scratch blocks -> command block morph -> private -> uncoloredArgMorphFor:
then delete all of that code and replace it with:)
uncoloredArgMorphFor: t1 | t2 | t2 _ t1 at: 2. $a = t2 ifTrue: [^ AttributeArgMorph new choice: 'volume']. $b = t2 ifTrue: [^ BooleanArgMorph new]. $c = t2 ifTrue: [^ ColorArgMorph new showPalette: true]. $C = t2 ifTrue: [^ ColorArgMorph new showPalette: false]. $d = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '0'; menuSelector: #directionMenu]. $D = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '48'; menuSelector: #midiDrumMenu]. $R = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #operatorNames; choice: '+']. $e = t2 ifTrue: [^ EventTitleMorph new]. $f = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #mathFunctionNames; choice: 'sqrt']. $g = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #graphicEffectNames; choice: 'color']. $j = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #engineNames; choice: 'google']. $H = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #hookupSensorNames]. $h = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #hookupBooleanSensorNames]. $I = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '1'; menuSelector: #midiInstrumentMenu]. $i = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '1'; menuSelector: #listIndexMenu]. $k = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #keyNames; choice: 'space']. $L = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #listVarMenu]. $l = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #costumeNames; choice: 'costume1']. $m = t2 ifTrue: [^ SpriteArgMorph new]. $M = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #motorNames]. $n = t2 ifTrue: [^ ExpressionArgMorph new numExpression: '10']. $N = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '60'; menuSelector: #noteSelector]. $s = t2 ifTrue: [^ ExpressionArgMorph new stringExpression: '']. $S = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #soundNames; choice: 'pop']. $v = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #varNamesMenu; choice: '']. $W = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #motorDirection]. $x = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #sceneNames; choice: '']. $y = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '1'; menuSelector: #listIndexForDeleteMenu]. ^ ExpressionArgMorph new numExpression: '10'
last bit of code (scratch objects -> scriptable scratch morph -> sensing ops ->)
engineNames
^ #('google' 'yahoo' 'scratch.mit.edu/' 'search scratch for' 'IMDB' 'load' )
What it does:
lets you search google, yahoo!, the scratch site, scratch.mit.edu and IMDB! (opens your default web browser)
Shared by lots of people
blockspec:
'clone me' #- #duplicateNoAttach
no code needed
What it does:
This block creates a clone of the sprite that runs it.Note: this block does not work in presentation mode.
Shared by lots of people
blockspec:
'delete me' #- #undoableDeleteSprite
no code needed
What it does:
This block permenantly deletes the sprite that runs it.Note: this block does not work in presentation mode.
Shared by Zorket
Blockspec:
('set single stepping' #- #setSpeed)
Code:
setSpeed
| t1 t2 |
t1 _ CustomMenu new title: 'Single-step speed?'.
t1 add: 'Turbo speed' action: 0.
t1 add: 'Normal' action: 1.
t1 add: 'Flash blocks (fast)' action: 30.
t1 add: 'Flash blocks (slow)' action: 200.
t2 _ t1 localize startUp.
t2 ifNil: [^ self].
ScratchProcess blockHighlightMSecs: t2
What it does:
This block lets you change the speed of your project! Very useful when you want a mix of fast computing and good graphics.
Shared by Pecola1
Blockspec:
('show cursor' #- #showCursor)
Code:
showCursor
World activeHand showTemporaryCursor: nil
What it does:
Shows the cursor (use with hide cursor block below).
Shared by Pecola1
Blockspec:
('hide cursor' #- #hideCursor)
Code:
hideCursor
World activeHand showTemporaryCursor: ((Form extent: 1 @ 1 depth: 32)
fillColor: Color transparent)
What it does:
hides the cursor.
Shared by Pecola1
Blockspec:
('enable programmer facilities' #- #enableProgrammerFacilities)
Code:
enableProgrammerFacilities
Preferences enableProgrammerFacilities
What it does:
Enables the programmer facilities (info).
Shared by Pecola1
Blockspec:
('quit Scratch' #- #exitScratch)
Code:
exitScratch
Smalltalk snapshot: false andQuit: true
What it does:
Closes Scratch. You'll need to save the image before testing it.
^ Back to Scratch Blocks
^ Back to Contents
Last edited by sparks (2011-01-13 16:20:01)
Offline
Looks
Shared by Jwosty
blockspec:
'say nothing' #- #sayNothing
no code needed
What it does:
hides a sprite's speech bubble. Equivalent to a say %s block with an empty string argument.
Shared by sonicjosh
blockspec:
'paint new costume' #- #drawNewCostume
no code needed
What it does:
Opens the paint editor and lets you paint a new sprite. Good for games where people want to choose their own avatars.
Shared by coupdegrace
blockspec:
('go forward %n layers' #- #goFwdByLayers: 1)
Code:
goFwdByLayers: t1
owner ifNil: [^ self].
self layer: (owner submorphs indexOf: self)
- t1 truncated
What it does:
Moves your sprite forward the specified amout of layers. (note, this can also be achieved by typing a negative number into the go back (n) layers block.
Shared by Pecola1
Click here for the 6 stage panning blocks.
What it does:
Pans the stage backround around.
Shared by Jens Mönig
blockspec:
('flip' #- #flip)
Code:
flip
costume form: (self form flipBy: #horizontal centerAt: 0 @ 0).
self costumeChanged
What it does:
Flips a sprite to give a mirror image costume.
Shared by Pecola1
blockspec:
('grab screen region for new sprite' #- #grabSpriteFromScreen)
Code:
no code needed
What it does:
Lets you grab a region of the screen to make a new sprite with.
Shared by Pecola1
blockspec:
('save picture of stage...' #- #stageShot)
Code:
no code needed
What it does:
Lets you save a picture of the stage.
Shared by Pecola1
blockspec:
('grab a new costume from stage' #- #grabFromScreen)
Code:
no code needed
What it does:
Lets you grab a region of the screen to make a new costume.
Shared by Pecola1
blockspec:
('layer #' #r #layer)
Code:
layer
^ owner submorphs indexOf: self
What it does:
Reports the layer number of your sprite.
Shared by Pecola1
blockspec:
('go to layer %n' #- #layer:)
Code:
no code needed
What it does:
moves your sprite to a new layer.
Shared by Pecola1
blockspec:
('name of costume # %n' #r #costumeNameFromNumber:)
Code:
no code needed
What it does:
reports the name of the costume number.
^ Back to Scratch Blocks
^ Back to Contents
Last edited by sparks (2011-01-13 16:17:25)
Offline
Sensing
Shared by Hardmath123.
Blockspec:
('costume center' #r #rotationCenter)
Code:
no code needed
What it does:
reports costume centre.
Shared by LS97
blockspec:
'get %s' #r #getTime: 'date'
Code
getTime: t1
t1 = 'date' ifTrue: [^ Date today].
t1 = 'short date' ifTrue: [^ Date today printFormat: #(1 2 3 $- 2 2 )].
t1 = 'time' ifTrue: [^ Time now].
t1 = 'seconds' ifTrue: [^ Time now seconds].
t1 = 'minutes' ifTrue: [^ Time now minutes].
t1 = 'hours' ifTrue: [^ Time now hours].
t1 = 'day' ifTrue: [^ Date today weekday].
t1 = 'help' ifTrue: [^ 'type date, short date, time, seconds, minutes, day, hours'].
^ 'Error!'
What it does:
Reports the date and time, including seconds, minutes, hours, day and date.
Shared by Pecola1.
Click here for the code
What it does:
Adds a lot of other sprite attributes to the original block.
Shared by Pecola1.
Click here for the code (2 blocks)
What it does:
Adds a lot of other keyboard keys to the current blocks.
Shared by Hardmath123
Blockspec:
('distance to x %n y %n' #r #dist:and:)
Code:
dist: t1 and: t2 ^ (self xpos - t1 * (self xpos - t1) + (self ypos - t2 * (self ypos - t2))) abs sqrt
What this block does:
reports the distance of the sprite from a given coordinate.
Shared by Pecola1
Blockspec:
( %m touching %m ?' #b #sprite:touching:)
Code:
sprite: t1 touching: t2 | t3 t4 t5 t6 t7 t8 t9 | t3 _ self coerceSpriteArg: t2. t3 = #mouse ifTrue: [(t4 _ self ownerThatIsA: ScratchStageMorph) ifNil: [^ false]. ^ t1 containsPoint: t4 adjustedCursorPoint]. t3 = #edge ifTrue: [^ t1 isOnEdge]. t1 = #mouse ifTrue: [(t4 _ self ownerThatIsA: ScratchStageMorph) ifNil: [^ false]. ^ t3 containsPoint: t4 adjustedCursorPoint]. (t3 isKindOf: t1 class) ifFalse: [^ false]. (t1 isHidden not and: [t3 isHidden not]) ifFalse: [^ false]. t5 _ t1 bounds intersect: t3 bounds. (t5 width > 0 and: [t5 height > 0]) ifFalse: [^ false]. t6 _ Form extent: t5 extent depth: 2. t7 _ t6 deepCopy. t9 _ self visibility. self visibility: 100. t1 drawOn: ((FormCanvas on: t6) copyOffset: t5 topLeft negated). t1 visibility: t9. t9 _ t3 visibility. t3 visibility: 100. t3 drawOn: ((FormCanvas on: t7) copyOffset: t5 topLeft negated). t3 visibility: t9. t8 _ Bitmap new: 4 withAll: 1. t8 at: 1 put: 0. t6 copyBits: t6 boundingBox from: t6 at: 0 @ 0 colorMap: t8. t7 copyBits: t7 boundingBox from: t7 at: 0 @ 0 colorMap: t8. t7 displayOn: t6 at: 0 @ 0 rule: Form and. ^ (t6 tallyPixelValues at: 1) < (t6 width * t6 height)
What this block does:
reports whether two sprites (or the mouse-pointer) are touching.
^ Back to Scratch Blocks
^ Back to Contents
Last edited by sparks (2011-01-13 16:25:32)
Offline
Sound
Shared by PlayWithFire
blockspec:
'import sound' #- #importSound
no code needed
What this block does:
this block allows you to import a sound.
Shared by Sparks
blockspec:
'record sound' #- #recordSound
no code needed
What it does:
Opens the sound recording window and lets you record a sound.
^ Back to Scratch Blocks
^ Back to Contents
Last edited by sparks (2010-10-11 13:46:44)
Offline
Operators
Shared by Zorket.
Blockspec:
('report %s' #r #report: 'hello')
Code:
report: t1
^ t1
What it does:
Reports it's contents. Useful for putting text in areas where it normally can't go. (such as the [go to $Sprites$] block.
Shared by Zorket, optimised by nXIII
Blockspec:
('if %b then %s else %s' #r #if:then:else:)
Code:
if: t1 then: t2 else: t3
t1 ifTrue: [^ t2].
^ t3
What it does:
reports the first string argument if the boolean is true, the second if it's false.
Shared by Zorket
Blockspec
'if %b then %b else %b' #b #if:then:else:
Code:
if: t1 then: t2 else: t3
t1 ifTrue: [^ t2].
^ t3
What it does
reports the truth of the first or second boolean argument depending on the truth of the first.
Shared by Zorket
Blockspec
'true' #b #reportTrue
Code:
reportTrue
^ true
What it does
reports true
Shared by Zorket
Blockspec
'false' #b #reportFalse
Code:
reportFalse
^ false
What it does
reports false
Shared by Zorket
Blockspec
('%T %s' #r #do:to:)
do: t1 to: t2 t1 = 'reverse' ifTrue: [^ t2 reversed]. t1 = 'shuffle' ifTrue: [^ t2 shuffled]. t1 = 'uppercase' ifTrue: [^ t2 asUppercase]. t1 = 'lowercase' ifTrue: [^ t2 asLowercase]. t1 = 'report' ifTrue: [^ t2].
Scratch blocks> commandBlockMorph> all> uncoloredArgMorphFor: add a strip:
$T = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #mixingNames; choice: 'reverse'].
Scratch objects> scriptableScratchMorph> LOW then press class> otherOps:
mixingNames ^ #('lowercase' 'uppercase' 'reverse' 'shuffle' 'report' )
Shared by Hardmath123.
Blockspec:
('%b' #r #booleanstring:)
Code:
booleanstring: t1
^ t1
What it does:
Allows you to drop booleans into reporter spaces!
Shared by Hardmath123.
Blockspec:
('%n ^ %n' #r #x:expy: 2 2)
Code:
x: t1 expy: t2
^ t1 raisedTo: t2
What it does:
reports n1 to the power of n2
Shared by Pecola1.
Blockspec:
('ascii for %s' #r #asciicodeof:)
Code:
asciicodeof: aString
| str |
str _ aString asMacRoman.
str size = 1 ifFalse: [^ 0].
^ str first asciiValue
What it does:
Reports the ascii code for an entered character
Shared by Pecola1.
Blockspec:
('ascii %n as character' #r #asciiLetter:)
Code:
asciiLetter: anInteger
| code |
code _ anInteger asNumberNoError.
^ String with: (Character value: code)
What it does:
Reports character the entered ascii code stands for.
Shared by Hardmath123.
Blockspec:
('%T' #r #getconstant:)
Code:
getconstant: t1
t1 = 'pi' ifTrue: [^ '3.141592653'].
t1 = 'phi' ifTrue: [^ '1.61803399'].
t1 = 'e' ifTrue: [^ '2.71828183'].
t1 = 'sqrt 2' ifTrue: [^ '1.41421356'].
^ 3.141592653
Scratch-Objects»ScriptableScratchMorph»sensing
constants
^ #('pi' 'phi' 'e' 'sqrt 2' )
Scratch-Blocks»CommandBlockMorph»-- all --»uncoloredArgMorphFor:
REPLACE ALL WITH
uncoloredArgMorphFor: t1 | t2 | t2 _ t1 at: 2. $a = t2 ifTrue: [^ AttributeArgMorph new choice: 'volume']. $b = t2 ifTrue: [^ BooleanArgMorph new]. $c = t2 ifTrue: [^ ColorArgMorph new showPalette: true]. $C = t2 ifTrue: [^ ColorArgMorph new showPalette: false]. $d = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '0'; menuSelector: #directionMenu]. $D = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '48'; menuSelector: #midiDrumMenu]. $e = t2 ifTrue: [^ EventTitleMorph new]. $f = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #mathFunctionNames; choice: 'sqrt']. $g = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #graphicEffectNames; choice: 'color']. $H = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #hookupSensorNames]. $h = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #hookupBooleanSensorNames]. $I = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '1'; menuSelector: #midiInstrumentMenu]. $i = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '1'; menuSelector: #listIndexMenu]. $k = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #keyNames; choice: 'space']. $L = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #listVarMenu]. $l = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #costumeNames; choice: 'costume1']. $m = t2 ifTrue: [^ SpriteArgMorph new]. $M = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #motorNames]. $n = t2 ifTrue: [^ ExpressionArgMorph new numExpression: '10']. $N = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '60'; menuSelector: #noteSelector]. $s = t2 ifTrue: [^ ExpressionArgMorph new stringExpression: '']. $S = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #soundNames; choice: 'pop']. $v = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #varNamesMenu; choice: '']. $W = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #motorDirection]. $x = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #sceneNames; choice: '']. $y = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '1'; menuSelector: #listIndexForDeleteMenu]. $T = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #constants; choice: 'pi']. ^ ExpressionArgMorph new numExpression: '10'
What it does:
Reports the selected constant.
Shared by Hardmath123.
Blockspec:
('%b=%b' #b #a:equalsb:)
Code:
a:t1 equalsb:t2
t1 = t2 ifTrue [^true].
^false.
What it does:
Reports wether or not the two booleans are equal.
Shared by ESN.
Click here for the block code.
What it does:
Reports a fraction of a number from a dropdown.
Shared by Hardmath123.
Blockspec:
('%b=%b' #b #a:equalsb:)
Code:
a:t1 equalsb:t2
t1 = t2 ifTrue [^true].
^false.
What it does:
Reports wether or not the two booleans are equal.
Shared by Zorket.
Blockspec
('letter %n of the alphabet' #r #letter:)
Code:
letter: t1 t1 = 1 ifTrue: [^ 'a']. t1 = 2 ifTrue: [^ 'b']. t1 = 3 ifTrue: [^ 'c']. t1 = 4 ifTrue: [^ 'd']. t1 = 5 ifTrue: [^ 'e']. t1 = 6 ifTrue: [^ 'f']. t1 = 7 ifTrue: [^ 'g']. t1 = 8 ifTrue: [^ 'h']. t1 = 9 ifTrue: [^ 'i']. t1 = 10 ifTrue: [^ 'j']. t1 = 11 ifTrue: [^ 'k']. t1 = 12 ifTrue: [^ 'l']. t1 = 13 ifTrue: [^ 'm']. t1 = 14 ifTrue: [^ 'n']. t1 = 15 ifTrue: [^ 'o']. t1 = 16 ifTrue: [^ 'p']. t1 = 17 ifTrue: [^ 'q']. t1 = 18 ifTrue: [^ 'r']. t1 = 19 ifTrue: [^ 's']. t1 = 20 ifTrue: [^ 't']. t1 = 21 ifTrue: [^ 'u']. t1 = 22 ifTrue: [^ 'v']. t1 = 23 ifTrue: [^ 'w']. t1 = 24 ifTrue: [^ 'x']. t1 = 25 ifTrue: [^ 'y']. t1 = 26 ifTrue: [^ 'z']. ^ 'ERROR!'
What it does:
Gives you the letter from the alphabet corresponding to the number you enter.
Shared by Pecola1.
Blockspec:
('report %b or %b randomly' #b #booleanRandom:Or:)
Code:
booleanRandom: t1 Or: t2
| t3 |
t3 _ self randomFrom: 0 to: 1.
t3 = 1 ifTrue: [^ t1].
^ t2
What it does:
Reports it's contents. Useful for putting text in areas where it normally can't go. (such as the [go to $Sprites$] block.
Shared by Zorket.
Blockspec:
('%n %s %n' #r #workOut:with:to:)
Code:
workOut: t1 with: t2 to: t3
t2 = '+' ifTrue: [^ t1 + t3].
t2 = '-' ifTrue: [^ t1 - t3].
t2 = '*' ifTrue: [^ t1 * t3].
t2 = '/' ifTrue: [^t1 / t3].
^ error!
What it does:
Designed to replaces the +, -, * and / reporter blocks.
Shared by Pecola1.
Blockspec:
('%s as boolean' #b #stringAsBoolean)
Code:
stringAsBoolean: t1
| t2 |
t2 _ t1 asString.
(t2 = '0'
or: [t2 = '' or: [t2 = 'false']])
ifTrue: [^ false].
^ true
What it does:
reports true if the string is "true", otherwise it reports false.
Shared by Hardmath123.
Blockspec:
('greater of %n and %n' #r #greater:and:)
Code:
greater: t1 and: t2
t1 > t2 ifTrue: [^ t1].
^ t2
What it does:
reports the greater of the two values.
Shared by Hardmath123.
Blockspec:
('lesser of %n and %n' #r #greater:and:)
Code:
lesser: t1 and: t2
t1 < t2 ifTrue: [^ t1].
^ t2
What it does:
reports the lesser of the two values.
^ Back to Scratch Blocks
^ Back to Contents
Last edited by sparks (2011-01-13 15:35:34)
Offline
Pen
Shared by jonathanpb
blockspec:
'pen size' #r #penSize
no code needed
What it does:
Reports the current pen size.
Shared by zorket
blockspec:
'pen down?' #b #penDown
no code needed
What it does:
Reports wether the pen for that sprite is down or not.
Shared by jwosty
blockspec:
'pen shade' #r #penShade
code
penShade
^ penShade
What it does:
Reports the shade of the sprite's pen.
Shared by jwosty
blockspec:
'pen color' #r #penHue
code
penHue
^ penHue
What it does:
Reports the pen color.
^ Back to Scratch Blocks
^ Back to Contents
Last edited by sparks (2010-10-11 13:47:44)
Offline
Variables
Shared by Hardmath123.
Blockspec:
('make new variable' #- #addGlobalVariable)
Code:
no code needed
What it does:
creates a new variable!
Shared by Pecola1.
Blockspec:
('move %v to x: %n y: %n' #- #moveVar:toX:y: '' 0 0)
Code:
positionVar: t1 atX: t2 y: t3 | t4 t5 t6 t7 t8 t9 | (self varNames includes: t1) ifFalse: [^ self]. t4 _ self ownerThatIsA: ScratchFrameMorph. t4 ifNil: [(t5 _ self ownerThatIsA: OffscreenWorldMorph) ifNil: [^ self]. t4 _ t5 frame]. t6 _ VariableBlockMorph new commandSpec: t1; receiver: self blockReceiver. (t5 _ t4 watcherForBlock: t6) ifNil: [^ self]. t7 _ t2. t7 isNaN ifTrue: [t7 _ 0]. t7 > 240 ifTrue: [t7 _ 240]. t7 < (-240 - t5 extent x) ifTrue: [t7 _ -240 - t5 extent x]. t8 _ t3. t8 isNaN ifTrue: [t8 _ 0]. t8 < -180 ifTrue: [t8 _ -180]. t8 > (180 + t5 extent y) ifTrue: [t8 _ 180 + t5 extent y]. t9 _ t7 @ t8 negated. t5 position: ScratchOrigin + t9
Second code
moveVar: t1 toX: t2 y: t3 | t4 | self positionVar: t1 atX: t2 y: t3. t4 _ self ownerThatIsA: ScratchStageMorph. t4 ~= self ifTrue: [t4 positionVar: t1 atX: t2 y: t3]
What it does:
Changes the position of a variable watcher on the Stage.
^ Back to Scratch Blocks
^ Back to Contents
Last edited by sparks (2011-01-13 14:43:14)
Offline
. Visit the BYOB site
how to add one of these blocks:
You need to download BYOB (Build Your Own Blocks) from this link
How do I make a custom BYOB block?
To view all the downloadable BYOB blocks click here (thanks to meowmeow55 for this feature)
Choose a block type to view, or scroll down this page to see more!
Motion
Control
Looks
Sensing
Sound
Operators
Pen
Variables
home
Last edited by sparks (2011-01-03 13:42:03)
Offline
Motion
Shared by jonathanpb
Shared by PlayWithFire
Shared by SSBBM
Shared by Guinea_Pig_Girl
Shared by SSBBM
Shared by Guinea_Pig_Girl.
Shared by owetre18.
Shared by meowmeow55.
_____________________________
^ Back to BYOB Blocks
^ Back to Contents
Last edited by sparks (2011-01-13 15:40:43)
Offline
Control
Shared by midnightleopard
(code) (spec) Shared by MidnightLeopard
Shared by SSBBM (credit to zxz1661)
Shared by SSBBM
Shared by SSBBM
Shared by meowmeow55
Shared by SSBBM
Shared by SSBBM
Shared by ESN
_____________________________
^ Back to BYOB Blocks
^ Back to Contents
Last edited by sparks (2011-01-13 14:57:44)
Offline
Looks
Shared by jonathanpb
Shared by jonathanpb
Shared by jonathanpb
Shared by PlayWithFire
Shared by PlayWithFire
Shared by SSBBM
Shared by SSBBM
Shared by SSBBM
Shared by SSBBM
Shared by owetre18
_____________________________
^ Back to BYOB Blocks
^ Back to Contents
Last edited by sparks (2011-01-03 14:13:19)
Offline
Sensing
Shared by PlayWithFire
Shared by PlayWithFire
Shared by SSBBM
Shared by SSBBM
Shared by SSBBM
Shared by ScratchReallyROCKS
Shared by thecrazyguy and improved by Pecola1
Shared by subzerostig
Shared by subzerostig
_____________________________
^ Back to BYOB Blocks
^ Back to Contents
Last edited by sparks (2011-01-13 16:05:49)
Offline
Sound
Shared by TheSuccessor
_____________________________
^ Back to BYOB Blocks
^ Back to Contents
Last edited by sparks (2010-12-12 11:59:08)
Offline
Operators
Shared by meowmeow55
Shared by PlayWithFire
Shared by PlayWithFire
Shared by meowmeow55Note, unlike the normal equals boolean, this one is case sensitive!
Shared by rdococ
Shared by bbbeb
Shared by SSBBM
Shared by SSBBM
Shared by SSBBM
Shared by meowmeow55
Shared by meowmeow55
Shared by SSBBM
Shared by meowmeow55
Shared by meowmeow55
Shared by sid_the_great
Shared by subzerostig
Shared by subzerostig
Shared by SSBBM
Shared by sid_the_great and Sparks
Shared by sid_the_great and Sparks
Shared by sid_the_great and Sparks
Shared by SSBBM
Shared by Pecola1
Shared by Pecola1
Shared by Pecola1
Shared by Pecola1
Shared by Pecola1
_____________________________
^ Back to BYOB Blocks
^ Back to Contents
Last edited by sparks (2011-01-13 13:38:06)
Offline
Pen
Shared by PlayWithFire
Shared by Jonathanpb
Shared by Chrischb
Shared by Chrischb
Shared by SSBBM
Shared by SSBBM(updated)
Shared by SSBBM
Shared by SSBBM
Shared by subzerostig
Shared by subzerostig
_____________________________
^ Back to BYOB Blocks
^ Back to Contents
Last edited by sparks (2010-12-12 12:02:36)
Offline
Variables
Shared by nXIII
Shared by owetre18
Shared by SSBBM
Shared by SSBBM
Shared by ScratchReallyROCKS
Shared by Pecola1
Shared by SSBBM
Shared by Guinea_Pig_Girl
_____________________________
^ Back to BYOB Blocks
^ Back to Contents
Last edited by sparks (2011-01-13 14:54:45)
Offline