billyedward wrote:
Let's begin with the blank gray screen of squeak. First left click on that gray, select “open…,” and select “Scratch/Streak”.
This opens a draggable-around Scratch/Streak window.
To resize hold alt and click on the window, and drag the “http://docs.google.com/File?id=dfbw6jtq_5dcbq9sgj_b”pin.
OK, now do the same as above, but this time select “browser” from the “open” list.
This opens the system browser, what most of the programming will go in to:
http://docs.google.com/File?id=dfbw6jtq_6g8wb8ffw_b
The little green circle allows you to resize this window. Just hover over the edge to get it. The X quits the window, the “O” minimizes, and the paper opens the window options. You’ll notice the 4 navigation panes above, and the coding pane below. These let you navigate and change the hierarchy of Scratch/Streak. The “instance|?|class”
Is for the 3 main categories. “Class” generally defines that an object exists, whereas instance defines what it does. ? is for comments, which don’t work. Lets get started. Navigate as follows: 1 Scratch-Objects, 2 ScriptableScratchMorph, 3 Class, 4 Scratch, 5 Blockspecs:
http://docs.google.com/File?id=dfbw6jtq_7g2h7smz6_b
See how I highlighted “(‘if %b’ #c #doIfElse)”? This is the basic syntax for defining the existence of a block. There is:
• opening bracket
• single quote
• The text to be displayed on the block, input areas represented by %letter, such as %n is a numerical inserter, %b is Boolean. Here's the full list:Code:
a:attribute of another sprite, such as X position or size. b:a boolean inserter c:a colour picker that shows the menu. C:a colour picker that doesn't d: the sprite direction menu/numerical inserter. D: the menu for midi drums e: The broadcast message menu f: math function menu (with sin, abs, etc.) g: menu for the different graphic effects. h: numerical sensor board selector menu H: boolean sensor board selector menu i: midi instrument menu/numerical inserter k: menu for the names of the different keys, used in the key sensor blocks. l: menu with the costume names of the given sprite. L: list name menu. m: sprite list n: numerical inserter N: note name menu/inserter s: string inserter S: sound selector menu v: variable labels menu y: menu used to delete either a number of the last value or all of a list.• Single quote
• “#” sign.
• Letter representing the block type, - being a normal command block, b is Boolean, r a reporter, c is a bar.
• “#” sign.
• Message to be corresponded in the instance side.
• This may be followed by Another one or few stand alone numbers, # followed by a number, or value in single quotes. These define the default value of the inserters.
• Closing bracket.
The message can also define special forms, such as the above’s corresponding function tells how to do the else bar.
What we now want to do is go over to “obsoleteBlockSpecs.”
Highlight each section…
http://docs.google.com/File?id=dfbw6jtq_8hgcctqcb_b
And Copy/Paste into the corresponding section of “blockSpecs”: (See that ‘numbers’ before? All following this will show under numbers.
http://docs.google.com/File?id=dfbw6jtq_9gp3qj8qg_b
Now right click “accept”
http://docs.google.com/File?id=dfbw6jtq_10fc4ndbhf_b
Et Voila! You’ve resurrected an “obsolete” block!
Repeat this process for the rest. These blocks will work in normal Scratch/Streak, they’ll just be red.
Now that we have the obsoletes’, lets try some other cheats. Go to:
1 Scratch-Objects, 2 ScratchSpriteMorph, 3 Class, 4 Scratch, 5 Blockspecs:
http://docs.google.com/File?id=dfbw6jtq_11gjcfqxhr_b
See in the single quotes of both where it’s says 'color'?
Change this to, say saturation: http://docs.google.com/File?id=dfbw6jtq_12mfv7z8j9_b
Which, when accepted, gives this: http://docs.google.com/File?id=dfbw6jtq_13dhrqhmfp_b, Which produces this:
http://docs.google.com/File?id=dfbw6jtq_14fhp7krfn_b
Neat,eh? Try setting it to blur, pointillize, or water as well!
One more thing: go back to 1 Scratch-Objects, 2 ScriptableScratchMorph, 3 Class, 4 Scratch, 5 Blockspecs, and find the equals block: http://docs.google.com/File?id=dfbw6jtq_15ftx4x6gx_b. See the
‘#- #-‘? This means that the two inserters will be blank. If, however, you put a string into them (replacing the dash), then they will be forced to hold it. How scratch does this is to “temporarily” make it a square string inserter. (http://docs.google.com/File?id=dfbw6jtq_16ck3hc4hb_b) You could also change the “%n” to a “%s” which is the “code” for a string inserter, but that would render it incompatible with normal Scratch/Streak. Using the above methods you can also make entirely new blocks: http://docs.google.com/File?id=dfbw6jtq_17zfzs5fgb_b
And force stuff into other blocks:
http://docs.google.com/File?id=dfbw6jtq_19g3fbvmhp_b
Another thing you can do is:
Drag a block out to the gray, and Alt+click it.
http://docs.google.com/File?id=dfbw6jtq_207s5gjkgp_b
Click the red menu icon, and select change colour…
Edit as you wish… And use in your Scripts!
http://docs.google.com/File?id=dfbw6jtq_21drvvf8ds_b
http://docs.google.com/File?id=dfbw6jtq_22dmrfrqdp_b
Certain other blocks can only easily be gotten by going to the version of Scratch/Streak it came from. The 1.2beta comment block is an example:
http://docs.google.com/File?id=dfbw6jtq_23crr4pwd4_b
It’ll show up red in everything after 1.1, gray in 1.2beta. It is obsolete before 1.2.
Hope this helps in your endeavor to utilise the scratch source code!
I will make a more advanced collection of information soon, for those who want to continue.
Oh, great master of the source code: Will you teach us the blocks in the image?
Offline
Please.
Offline
I want all the blocks spec and the code for each one to work!
Offline
kinker wrote:
I want all the blocks spec and the code for each one to work!
and do it nao or else u will be making a bad mistake.
Offline
kinker wrote:
kinker wrote:
I want all the blocks spec and the code for each one to work!
and do it nao or else u will be making a bad mistake.
Dude. Find it out yourself. Learn some coding and please stop trying to make others do things that you can do yourself!
Offline
Once you've hacked into Scratch, and used the Change Sorter, how do you save the program?
Offline
-Stendika- wrote:
Once you've hacked into Scratch, and used the Change Sorter, how do you save the program?
to save the image? are you doing this in normal scratch or the source?
Offline
Basically, how do you save a new version of the source code?
Offline
BUT HOW DO YOU SAVE IT?!?!?
"Save image for end-user" just freezes it up...
Offline
Never mind. I got it. I'm working on a simple scratch mod called "shred" right now.
Offline
As this is an ITopic, you might want to update this for scratch 1.4.
Also, the %i is the 1/last/any of a list, while %I is the MIDI instruments.
Thanks.
Offline
billyedward wrote:
a:attribute of another sprite, such as X position or size.
b:a boolean inserter
c:a colour picker that shows the menu.
C:a colour picker that doesn't
d: the sprite direction menu/numerical inserter.
D: the menu for midi drums
e: The broadcast message menu
f: math function menu (with sin, abs, etc.)
g: menu for the different graphic effects.
h: numerical sensor board selector menu
H: boolean sensor board selector menu
i: midi instrument menu/numerical inserter
k: menu for the names of the different keys, used in the key sensor blocks.
l: menu with the costume names of the given sprite.
L: list name menu.
m: sprite list
n: numerical inserter
N: note name menu/inserter
s: string inserter
S: sound selector menu
v: variable labels menu
y: menu used to delete either a number of the last value or all of a list.
I have a question: When I use %m in my custom blocks, the dropdown list contains mouse pointer, which isn't a sprite. But in the block ''%a of %m', the dropdown list does NOT contain the mouse pointer, and instead contains the stage. Why is that? Isn't the coding the same?
Offline
well, there seems to be something in Scratch-Blocks -> SpriteArgMorph -> event handling -> fixGetAttribueBlock that makes it come out right. i don't know how its done.
Wait: its in the present menu.
presentMenu | t1 t2 t3 t4 t5 | (t1 _ self ownerThatIsA: ScratchFrameMorph) ifNil: [^ self]. (owner isKindOf: CommandBlockMorph) ifTrue: [t2 _ owner selector]. t3 _ t1 scratchObjects. t3 sort: [:t6 :t7 | t6 objName asLowercase < t7 objName asLowercase]. t4 _ CustomMenu new. t2 = #getAttribute:of: ifTrue: [t4 add: 'Stage' localized asUTF8 action: t1 workPane] ifFalse: [t4 add: 'mouse-pointer' localized asUTF8 action: #mouse. t2 = #touching: ifTrue: [t4 add: 'edge' localized asUTF8 action: #edge]. t3 _ t3 copyWithout: owner receiver]. t3 size > 0 ifTrue: [t4 addLine]. t3 do: [:t8 | t4 add: t8 objName action: t8]. (t5 _ t4 startUp) ifNil: [^ self]. morph _ t5. self fixGetAttribueBlock. self updateLabel
i don't understand it all, but if its the get attribute block, it adds stage, else, it adds mouse. if its the touching block, it also adds edge.
If you give the block and method, i'll give you the new code to replace that with.
Last edited by scimonster (2011-01-19 09:57:17)
Offline
Well, in fact, the block I was making at that time was 'make %m go to x: %n y: %n'
This, and the 'make %m move %n steps' block. You can't 'move' the mouse-pointer, can you? Nor can you move the Stage. So in this case, %m should just be a drop down list of all the sprites, NOT including the Stage, or the mouse pointer.
I think what happened in the coding of presentMenu, is the developers intended to make each sprite control itself, and all the blocks containing %m were used only to get the info, not to modify it. So the list was intended for blocks such as 'go to %m', and you COULD go to the mouse pointer, but you CANNOT move the mouse pointer.
Am I making sense or am I rambling?
Offline
you make sense, but i have to get offline now.
i'll do tommorow.
Offline
Necromaster wrote:
Cool! I'm experimenting with new blocks now...
cool! Do you know squeak? I have learned it a lot better! Good Luck!
Offline
hpotter134 wrote:
Well, in fact, the block I was making at that time was 'make %m go to x: %n y: %n'
This, and the 'make %m move %n steps' block. You can't 'move' the mouse-pointer, can you? Nor can you move the Stage. So in this case, %m should just be a drop down list of all the sprites, NOT including the Stage, or the mouse pointer.
I think what happened in the coding of presentMenu, is the developers intended to make each sprite control itself, and all the blocks containing %m were used only to get the info, not to modify it. So the list was intended for blocks such as 'go to %m', and you COULD go to the mouse pointer, but you CANNOT move the mouse pointer.
Am I making sense or am I rambling?
ok, put the code in Scratch-Blocks -> SpriteArgMorph (instance) -> event handling -> presentMenu.
presentMenu | t1 t2 t3 t4 t5 | (t1 _ self ownerThatIsA: ScratchFrameMorph) ifNil: [^ self]. (owner isKindOf: CommandBlockMorph) ifTrue: [t2 _ owner selector]. t3 _ t1 scratchObjects. t3 sort: [:t6 :t7 | t6 objName asLowercase < t7 objName asLowercase]. t4 _ CustomMenu new. t2 = #getAttribute:of: ifTrue: [t4 add: 'Stage' localized asUTF8 action: t1 workPane] ifFalse: t2 = #make:gotoX:y: ifFalse: [t4 add: 'mouse-pointer' localized asUTF8 action: #mouse. t2 = #touching: ifTrue: [t4 add: 'edge' localized asUTF8 action: #edge]. t3 _ t3 copyWithout: owner receiver]. t3 size > 0 ifTrue: [t4 addLine]. t3 do: [:t8 | t4 add: t8 objName action: t8]. (t5 _ t4 startUp) ifNil: [^ self]. morph _ t5. self fixGetAttribueBlock. self updateLabel
it also fixes for the sprite touching sprite block, if you have it.
if the method you are using is not what you shared to the library, change
ifFalse: t2 = #make:gotoX:y:
to whatever your method is.
Offline
Thanks for taking a look at it! I tried what you suggested, but it complains about the ifTrue:ifFalse:ifFalse:.
Is that valid Smalltalk? I don't think you can put two ifFalses in a row, can you?
Offline
maybe put a peroid after the first.
Offline
After a bit of trial and error, this worked best:
presentMenu | t1 t2 t3 t4 t5 | (t1 _ self ownerThatIsA: ScratchFrameMorph) ifNil: [^ self]. (owner isKindOf: CommandBlockMorph) ifTrue: [t2 _ owner selector]. t3 _ t1 scratchObjects. t3 sort: [:t6 :t7 | t6 objName asLowercase < t7 objName asLowercase]. t4 _ CustomMenu new. t2 = #getAttribute:of: ifTrue: [t4 add: 'Stage' localized asUTF8 action: t1 workPane] ifFalse: [t2 = #make:gotoX:y: ifFalse: [t4 add: 'mouse-pointer' localized asUTF8 action: #mouse. t2 = #touching: ifTrue: [t4 add: 'edge' localized asUTF8 action: #edge]. t3 _ t3 copyWithout: owner receiver]]. t3 size > 0 ifTrue: [t4 addLine]. t3 do: [:t8 | t4 add: t8 objName action: t8]. (t5 _ t4 startUp) ifNil: [^ self]. morph _ t5. self fixGetAttribueBlock. self updateLabel
This returned the proper drop-down lists!
Thanks scimonster!
Last edited by hpotter134 (2011-01-21 08:16:49)
Offline
Your welcome.
Glad to help where I can!
Offline