Where would you add these new block codes in Scratch 1.4? Is it possible to make new blocks in this version?
Offline
So, I need to modify my method for this block to convert things to forms.
My current code is:
addCostumeOf: t1 | t2 | t1 isForm ifFalse: [^ self]. t2 _ ImageMedia new form: t1; mediaName: (self unusedMediaNameFromBaseName: self defaultImageMedia mediaName). self addMediaItem: t2
Offline
Can you do:
<sprite drop-down list> (That's %m, right?) then another block, like "move x steps"
so the end result might be:
"Sprite1 move 10 steps"
That way, you can move another sprite.
Last edited by hpotter134 (2010-09-10 18:54:13)
Offline
hpotter134 wrote:
Can you do:
<sprite drop-down list> (That's %m, right?) then another block, like "move x steps"
so the end result might be:
"Sprite1 move 10 steps"
That way, you can move another sprite.
That wouldn't work.
It would really work like this:
method:
move: sprite forward: distance sprite forward: distance
spec:
('make %m move %n steps' #- #move:forward:)
Offline
I just finished a batch file for making scratch blocks!
@echo off cls Title Scratch Block Creator goto start :start cls echo Welcome to Scratch Block Creator 1.1! echo Codes: echo %n (round textbox) echo %s (textbox you can put anything in!) echo a (attribute of another sprite echo b (a boolean inserter) echo c (Color picker that shows the menu) echo C (Color picker that DOESN'T show the menu) echo d (Direction menu/numerical inserter) echo D (the menu for midi drums) echo e (The broadcast message menu) echo f (math function menu) echo g (menu with different graphic effects) echo h (numerical sensor board selector menu) echo H (boolean sensor board selector menu) echo i (midi instrument) echo k (key menu) echo l (costume names for the given sprite) echo L (List name menu) echo m (sprite list) echo n (numerical inserter) echo N (note name menu/inserter) echo s (string inserter) echo S (sound selector menu) echo v (variable labels menu) echo y (menu used to delete either a number of the last value or all of a list.) echo Block Types echo #- No arguments (command or 'stack' block) echo #r Round reporter block. echo #b boolean block (diamond shaped) echo #c C shaped block (e.g. the forever block) echo #t Time block (like wait 'n' secs) echo #W 'when' hat block (obsolete) echo #S Start buttin click hat block echo #E event hat block (broadcast) echo #s special form (difficult to code) echo Commands echo #doRepeat (repaeats) echo #getTime: (gets time) echo #getHidden (detects if you're showing) echo #grabFromScreen (grabs from the stage) echo #mousePressed: which mouse pause echo So, ready to code your block? Then...let's go! pause echo Type in your text! set/p "text=>" echo What type of block is it? set/p "block=>" echo Command? set/p "command=>" echo Any additional arguements? set/p "add=>" echo Here is your code: echo ('%text%' %block% %command% %add%) echo Copy and paste this block code into your scratch scripts available. echo Would you like to make another block? (y/n) set/p "yn=>" if %yn%==Y goto start if %yn%==y goto start if %yn%==N goto byebye if %yn%==n goto byebye :byebye exit
Offline
well how can this help with actually adding them to squeak?
by the way, instead of asking echo command you might want to use
prompt Command $g
Offline
Billybob-Mario wrote:
So, I need to modify my method for this block to convert things to forms.
My current code is:Code:
addCostumeOf: t1 | t2 | t1 isForm ifFalse: [^ self]. t2 _ ImageMedia new form: t1; mediaName: (self unusedMediaNameFromBaseName: self defaultImageMedia mediaName). self addMediaItem: t2
Anyone?
Last edited by Billybob-Mario (2010-09-11 08:20:02)
Offline
I see you managed the slot...
Offline
You mean, like,
| f m |
f_t1
f isForm ifFalse: [(f isKindOf: ImageMedia) ifTrue: [f_f form] ifFalse: [^self]].
m_ImageMedia new form: f; mediaName: (self unusedMediaNameFromBaseName: self defaultImageMedia mediaName).
self addMediaItem: m
Offline
TheSuccessor wrote:
I see you managed the slot...
I actually didn't. I just put in a block and recolored it.
Offline
LS97 wrote:
The key_pressed reporter block
a great block that saves you the fuss of making 30 scripts for each different key. just add this to a forever if and youre done with your scripting for a text program! add the block wherever you want, and add this code into the corresponding instance ops.Code:
(Sensor keyPressed: 65) ifTrue: [^ 'a']. (Sensor keyPressed: 66) ifTrue: [^ 'b']. (Sensor keyPressed: 67) ifTrue: [^ 'c']. (Sensor keyPressed: 68) ifTrue: [^ 'd']. (Sensor keyPressed: 69) ifTrue: [^ 'e']. (Sensor keyPressed: 70) ifTrue: [^ 'f']. (Sensor keyPressed: 71) ifTrue: [^ 'g']. (Sensor keyPressed: 72) ifTrue: [^ 'h']. (Sensor keyPressed: 73) ifTrue: [^ 'i']. (Sensor keyPressed: 74) ifTrue: [^ 'j']. (Sensor keyPressed: 75) ifTrue: [^ 'k']. (Sensor keyPressed: 76) ifTrue: [^ 'l']. (Sensor keyPressed: 77) ifTrue: [^ 'm']. (Sensor keyPressed: 78) ifTrue: [^ 'n']. (Sensor keyPressed: 79) ifTrue: [^ 'o']. (Sensor keyPressed: 80) ifTrue: [^ 'p']. (Sensor keyPressed: 81) ifTrue: [^ 'q']. (Sensor keyPressed: 82) ifTrue: [^ 'r']. (Sensor keyPressed: 83) ifTrue: [^ 's']. (Sensor keyPressed: 84) ifTrue: [^ 't']. (Sensor keyPressed: 85) ifTrue: [^ 'u']. (Sensor keyPressed: 86) ifTrue: [^ 'v']. (Sensor keyPressed: 87) ifTrue: [^ 'w']. (Sensor keyPressed: 88) ifTrue: [^ 'x']. (Sensor keyPressed: 89) ifTrue: [^ 'y']. (Sensor keyPressed: 90) ifTrue: [^ 'z']. (Sensor keyPressed: 32) ifTrue: [^ 'space']. (Sensor keyPressed: 1) ifTrue: [^ 'home']. (Sensor keyPressed: 4) ifTrue: [^ 'end']. (Sensor keyPressed: 5) ifTrue: [^ 'insert']. (Sensor keyPressed: 9) ifTrue: [^ 'tab']. (Sensor keyPressed: 11) ifTrue: [^ 'page up']. (Sensor keyPressed: 12) ifTrue: [^ 'page down']. (Sensor keyPressed: 127) ifTrue: [^ 'delete']. ^ 'none'Pretty long eh? don't be discouraged it's worth it!
is it possible to copy and pased it into scratch?
Offline
Alt-V is the same as paste in the squeak browser
Offline
nXIII wrote:
You mean, like,
| f m |
f_t1.
f isForm ifFalse: [(f isKindOf: ImageMedia) ifTrue: [f_f form] ifFalse: [^self]].
m_ImageMedia new form: f; mediaName: (self unusedMediaNameFromBaseName: self defaultImageMedia mediaName).
self addMediaItem: m
You left out a period. This also doesn't work for most costume blocks. For both this and the original, I was only able to get it to work using the ScratchSkin images as what to add through the (ScratchFrameMorph report code [ ]) block.
Offline
Billybob-Mario wrote:
nXIII wrote:
You mean, like,
| f m |
f_t1.
f isForm ifFalse: [(f isKindOf: ImageMedia) ifTrue: [f_f form] ifFalse: [^self]].
m_ImageMedia new form: f; mediaName: (self unusedMediaNameFromBaseName: self defaultImageMedia mediaName).
self addMediaItem: mYou left out a period. This also doesn't work for most costume blocks. For both this and the original, I was only able to get it to work using the ScratchSkin images as what to add through the (ScratchFrameMorph report code [ ]) block.
Then you coded it wrong. This is a generic ImageMedia block, so you're returning the wrong thing.
Offline
nXIII wrote:
Billybob-Mario wrote:
nXIII wrote:
You mean, like,
| f m |
f_t1.
f isForm ifFalse: [(f isKindOf: ImageMedia) ifTrue: [f_f form] ifFalse: [^self]].
m_ImageMedia new form: f; mediaName: (self unusedMediaNameFromBaseName: self defaultImageMedia mediaName).
self addMediaItem: mYou left out a period. This also doesn't work for most costume blocks. For both this and the original, I was only able to get it to work using the ScratchSkin images as what to add through the (ScratchFrameMorph report code [ ]) block.
Then you coded it wrong. This is a generic ImageMedia block, so you're returning the wrong thing.
I think that the people with the answer are Jens and/or bharvey. Slash is based on BYOB, and in BYOB, ^ self in a reporter returns an image of the sprite. They would know how to get and report that.
Offline
For the (key pressed) block
Blockspec: ('key pressed' #r #keyPressed)
Instead of using:
(Sensor keyPressed: 65) ifTrue: [^ 'a']. (Sensor keyPressed: 66) ifTrue: [^ 'b']. (Sensor keyPressed: 67) ifTrue: [^ 'c']. (Sensor keyPressed: 68) ifTrue: [^ 'd']. (Sensor keyPressed: 69) ifTrue: [^ 'e']. (Sensor keyPressed: 70) ifTrue: [^ 'f']. (Sensor keyPressed: 71) ifTrue: [^ 'g']. (Sensor keyPressed: 72) ifTrue: [^ 'h']. (Sensor keyPressed: 73) ifTrue: [^ 'i']. (Sensor keyPressed: 74) ifTrue: [^ 'j']. (Sensor keyPressed: 75) ifTrue: [^ 'k']. (Sensor keyPressed: 76) ifTrue: [^ 'l']. (Sensor keyPressed: 77) ifTrue: [^ 'm']. (Sensor keyPressed: 78) ifTrue: [^ 'n']. (Sensor keyPressed: 79) ifTrue: [^ 'o']. (Sensor keyPressed: 80) ifTrue: [^ 'p']. (Sensor keyPressed: 81) ifTrue: [^ 'q']. (Sensor keyPressed: 82) ifTrue: [^ 'r']. (Sensor keyPressed: 83) ifTrue: [^ 's']. (Sensor keyPressed: 84) ifTrue: [^ 't']. (Sensor keyPressed: 85) ifTrue: [^ 'u']. (Sensor keyPressed: 86) ifTrue: [^ 'v']. (Sensor keyPressed: 87) ifTrue: [^ 'w']. (Sensor keyPressed: 88) ifTrue: [^ 'x']. (Sensor keyPressed: 89) ifTrue: [^ 'y']. (Sensor keyPressed: 90) ifTrue: [^ 'z']. (Sensor keyPressed: 32) ifTrue: [^ 'space']. (Sensor keyPressed: 1) ifTrue: [^ 'home']. (Sensor keyPressed: 4) ifTrue: [^ 'end']. (Sensor keyPressed: 5) ifTrue: [^ 'insert']. (Sensor keyPressed: 9) ifTrue: [^ 'tab']. (Sensor keyPressed: 11) ifTrue: [^ 'page up']. (Sensor keyPressed: 12) ifTrue: [^ 'page down']. (Sensor keyPressed: 127) ifTrue: [^ 'delete']. ^ 'none'
A farther jumping code would be
keyPressed: t1 (Sensor keyPressed: 65) ifTrue: [^ 'a']. (Sensor keyPressed: 66) ifTrue: [^ 'b']. (Sensor keyPressed: 67) ifTrue: [^ 'c']. (Sensor keyPressed: 68) ifTrue: [^ 'd']. (Sensor keyPressed: 69) ifTrue: [^ 'e']. (Sensor keyPressed: 70) ifTrue: [^ 'f']. (Sensor keyPressed: 71) ifTrue: [^ 'g']. (Sensor keyPressed: 72) ifTrue: [^ 'h']. (Sensor keyPressed: 73) ifTrue: [^ 'i']. (Sensor keyPressed: 74) ifTrue: [^ 'j']. (Sensor keyPressed: 75) ifTrue: [^ 'k']. (Sensor keyPressed: 76) ifTrue: [^ 'l']. (Sensor keyPressed: 77) ifTrue: [^ 'm']. (Sensor keyPressed: 78) ifTrue: [^ 'n']. (Sensor keyPressed: 79) ifTrue: [^ 'o']. (Sensor keyPressed: 80) ifTrue: [^ 'p']. (Sensor keyPressed: 81) ifTrue: [^ 'q']. (Sensor keyPressed: 82) ifTrue: [^ 'r']. (Sensor keyPressed: 83) ifTrue: [^ 's']. (Sensor keyPressed: 84) ifTrue: [^ 't']. (Sensor keyPressed: 85) ifTrue: [^ 'u']. (Sensor keyPressed: 86) ifTrue: [^ 'v']. (Sensor keyPressed: 87) ifTrue: [^ 'w']. (Sensor keyPressed: 88) ifTrue: [^ 'x']. (Sensor keyPressed: 89) ifTrue: [^ 'y']. (Sensor keyPressed: 90) ifTrue: [^ 'z']. (Sensor keyPressed: 32) ifTrue: [^ 'space']. (Sensor keyPressed: 1) ifTrue: [^ 'home']. (Sensor keyPressed: 4) ifTrue: [^ 'end']. (Sensor keyPressed: 5) ifTrue: [^ 'insert']. (Sensor keyPressed: 9) ifTrue: [^ 'tab']. (Sensor keyPressed: 11) ifTrue: [^ 'page up']. (Sensor keyPressed: 12) ifTrue: [^ 'page down']. (Sensor keyPressed: 127) ifTrue: [^ 'delete']. ^ 'none'
But it still won't function.
Last edited by zorket (2010-09-11 14:58:51)
Offline
johnnydean1 wrote:
Alt-V is the same as paste in the squeak browser
thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you
Offline
ThePCKid wrote:
There's a better way to do the hidden block.
I'll use the Scratch source
Goto Scratch-Objects->ScratchSpriteMorph (class)->block specs->blockSpecs
Add this under the definition for the hide block:Code:
('hidden?' b isHidden)Replace the spaces with tabs (stupid FluxBB)
No, you don't have to make a new method.
i'll have said this for the 100000th time. my code is to get whether a sprite is SHOWING, not hiding. i know that's easier but it is more complicated for the user. you only make the squeak code once, but you use the block many more times.
Offline
sccar3 wrote:
johnnydean1 wrote:
Alt-V is the same as paste in the squeak browser
thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you
i wish i could do it. i'm stuck with cutting, pasting, and re-pasting because my ALT doesnt work (and the menu copy doesnt work either).
Offline
LS97 wrote:
The key_pressed reporter block
a great block that saves you the fuss of making 30 scripts for each different key. just add this to a forever if and youre done with your scripting for a text program! add the block wherever you want, and add this code into the corresponding instance ops.Code:
(Sensor keyPressed: 65) ifTrue: [^ 'a']. (Sensor keyPressed: 66) ifTrue: [^ 'b']. (Sensor keyPressed: 67) ifTrue: [^ 'c']. (Sensor keyPressed: 68) ifTrue: [^ 'd']. (Sensor keyPressed: 69) ifTrue: [^ 'e']. (Sensor keyPressed: 70) ifTrue: [^ 'f']. (Sensor keyPressed: 71) ifTrue: [^ 'g']. (Sensor keyPressed: 72) ifTrue: [^ 'h']. (Sensor keyPressed: 73) ifTrue: [^ 'i']. (Sensor keyPressed: 74) ifTrue: [^ 'j']. (Sensor keyPressed: 75) ifTrue: [^ 'k']. (Sensor keyPressed: 76) ifTrue: [^ 'l']. (Sensor keyPressed: 77) ifTrue: [^ 'm']. (Sensor keyPressed: 78) ifTrue: [^ 'n']. (Sensor keyPressed: 79) ifTrue: [^ 'o']. (Sensor keyPressed: 80) ifTrue: [^ 'p']. (Sensor keyPressed: 81) ifTrue: [^ 'q']. (Sensor keyPressed: 82) ifTrue: [^ 'r']. (Sensor keyPressed: 83) ifTrue: [^ 's']. (Sensor keyPressed: 84) ifTrue: [^ 't']. (Sensor keyPressed: 85) ifTrue: [^ 'u']. (Sensor keyPressed: 86) ifTrue: [^ 'v']. (Sensor keyPressed: 87) ifTrue: [^ 'w']. (Sensor keyPressed: 88) ifTrue: [^ 'x']. (Sensor keyPressed: 89) ifTrue: [^ 'y']. (Sensor keyPressed: 90) ifTrue: [^ 'z']. (Sensor keyPressed: 32) ifTrue: [^ 'space']. (Sensor keyPressed: 1) ifTrue: [^ 'home']. (Sensor keyPressed: 4) ifTrue: [^ 'end']. (Sensor keyPressed: 5) ifTrue: [^ 'insert']. (Sensor keyPressed: 9) ifTrue: [^ 'tab']. (Sensor keyPressed: 11) ifTrue: [^ 'page up']. (Sensor keyPressed: 12) ifTrue: [^ 'page down']. (Sensor keyPressed: 127) ifTrue: [^ 'delete']. ^ 'none'Pretty long eh? don't be discouraged it's worth it!
Yes.. unimaginably extremely long.
Try this: http://scratch.mit.edu/forums/viewtopic … 91#p359991
Offline