whizzer wrote:
whizzer wrote:
*Laughs* I think the code is like when you put stuff in the workspace and file-it-in. Just put the code in and save it as a .block file!
Does anyone value my opinion?
Yes, I see that.
Anyone want to try that?
Offline
I really want this!
Offline
origami3 wrote:
could I help I love Making New blocks In scratch and BYOB
Whit should I do To start?
We're making code for blocks in Smalltalk/Squeak.
I'm going to have a look at some stuff to see if we can do something.
Offline
scimonster wrote:
origami3 wrote:
could I help I love Making New blocks In scratch and BYOB
Whit should I do To start?We're making code for blocks in Smalltalk/Squeak.
I'm going to have a look at some stuff to see if we can do something.
ok I am learning Squeak
Offline
fuz50 wrote:
I'll help! Just a little confused on how to switch the file to a .block file once you have the code typed in. Help understanding that please?
Well, I was going to do it in Notepad and just save with the extension .block.
Offline
'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 05 September 2011 at 6:23:31 pm'! !ScriptableScratchMorph methodsFor: 'block specs'! blockSpecs | t1 | t1 _ #('control' ('when %m clicked' #S #-) ('when %k key pressed' #K #-) ('when %m clicked' #M #-) #- ('wait %n secs' #t #wait:elapsed:from: 1) #- ('forever' #c #doForever) ('repeat %n' #c #doRepeat 10) #- ('broadcast %e' #- #broadcast:) ('broadcast %e and wait' #s #doBroadcastAndWait) ('when I receive %e' #E #-) #- ('forever if %b' #c #doForeverIf) ('if %b' #c #doIf) ('if %b' #c #doIfElse) ('wait until %b' #s #doWaitUntil) ('repeat until %b' #c #doUntil) #- ('stop script' #s #doReturn) ('stop all' #- #stopAll) #- ('set single stepping' #- #setSpeed) 'operators' ('%n + %n' #r #+ #- #-) ('%n - %n' #r #- #- #-) ('%n * %n' #r #* #- #-) ('%n / %n' #r #/ #- #-) #- ('pick random %n to %n' #r #randomFrom:to: 1 10) #- ('%s < %s' #b #< '' '') ('%s = %s' #b #= '' '') ('%s > %s' #b #> '' '') #- ('%b and %b' #b #&) ('%b or %b' #b #|) ('not %b' #b #not) #- ('join %s %s' #r #concatenate:with: 'hello ' 'world') ('letter %n of %s' #r #letter:of: 1 'world') ('length of %s' #r #stringLength: 'world') #- ('%n mod %n' #r #\\ #- #-) ('round %n' #r #rounded #-) #- ('%f of %n' #r #computeFunction:of: 'sqrt' 10) 'sound' ('play sound %S' #- #playSound:) ('play sound %S until done' #s #doPlaySoundAndWait) ('stop all sounds' #- #stopAllSounds) #- ('play drum %D for %n beats' #t #drum:duration:elapsed:from: 48 0.2) ('rest for %n beats' #t #rest:elapsed:from: 0.2) #- ('play note %N for %n beats' #t #noteOn:duration:elapsed:from: 60 0.5) ('set instrument to %I' #- #midiInstrument: 1) #- ('change volume by %n' #- #changeVolumeBy: -10) ('set volume to %n%' #- #setVolumeTo: 100) ('volume' #r #volume) #- ('change tempo by %n' #- #changeTempoBy: 20) ('set tempo to %n bpm' #- #setTempoTo: 60) ('tempo' #r #tempo) 'motor' ('motor on for %n secs' #t #motorOnFor:elapsed:from: 1) ('motor on' #- #allMotorsOn) ('motor off' #- #allMotorsOff) ('motor power %n' #- #startMotorPower: 100) ('motor direction %W' #- #setMotorDirection: 'this way') 'variables' ('show variable %v' #- #showVariable:) ('hide variable %v' #- #hideVariable:) 'list' ('add %s to %L' #- #append:toList: 'thing') #- ('delete %y of %L' #- #deleteLine:ofList: 1) ('insert %s at %i of %L' #- #insert:at:ofList: 'thing' 1) ('replace item %i of %L with %s' #- #setLine:ofList:to: 1 'list' 'thing') #- ('item %i of %L' #r #getLine:ofList: 1) ('length of %L' #r #lineCountOfList:) ('%L contains %s' #b #list:contains: 'list' 'thing') ). ^ t1 , self obsoleteBlockSpecs! ! !ScriptableScratchMorph methodsFor: 'other ops'! 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! !
Stage one: the code is complete.
I will work on making stage two: the file later.
Offline
Great job, whizzer! I was thinking of something like that, but the problem is that it has to be able to add any block. So I was thinking of having 9 new methods that get created with the original installer, the new blockspec list for each category. Then, it adds the new one to the old. But... how can I have it not overwrite it?
Offline
scimonster wrote:
Great job, whizzer! I was thinking of something like that, but the problem is that it has to be able to add any block. So I was thinking of having 9 new methods that get created with the original installer, the new blockspec list for each category. Then, it adds the new one to the old. But... how can I have it not overwrite it?
Yeah. That's the problem. The code assumes people are using Scratch with no add-ons, and overwrites any previous blocks.
However, as soon as I can, I am still going to test it as a BLOCK file.
Offline
I'm working on something that uses the installer to create variables, and from there it will work.
Offline
Can't wait till this is done.
Offline
So here's what I've tried so far.
I save the following code as "test.block" and try to import it.
'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 09 September 2011 at 5:29:43 pm'! ScriptableScratchMorph subclass: #ScratchSpriteMorph instanceVariableNames: 'scalePoint rotationDegrees rotationStyle rotatedForm offsetWhenRotated draggable penDown penSize penColor penHue penShade ' classVariableNames: 'NewBlocks NewBlocksAdded Scratch ' poolDictionaries: '' category: 'Scratch-Objects'! !ScratchSpriteMorph methodsFor: 'initialization'! initialize super initialize. scalePoint _ 1.0 @ 1.0. rotationDegrees _ 0.0. rotationStyle _ #normal. rotatedForm _ self costumeForm. offsetWhenRotated _ 0 @ 0. draggable _ false. penDown _ false. penSize _ 1. penHue _ 133.3. penShade _ 50. NewBlocksAdded _ false. self penColor: Color blue. self extent: rotatedForm extent ! ! !ScratchSpriteMorph methodsFor: 'block specs'! addNewBlocks NewBlocksAdded ifFalse: [NewBlocks _ NewBlocks , #('looks' ('go forward %n layers' #- #goFwdByLayers: 1) ). NewBlocksAdded _ true] ! ! !ScratchSpriteMorph methodsFor: 'block specs'! blockSpecs | t1 | self addNewBlocks. t1 _ #('motion' ('move %n steps' #- #forward:) ('turn %n degrees' #- #turnRight: 15) ('turn %n degrees' #- #turnLeft: 15) #- ('point in direction %d' #- #heading: 90) ('point towards %m' #- #pointTowards:) #- ('go to x:%n y:%n' #- #gotoX:y: 0 0) ('go to %m' #- #gotoSpriteOrMouse:) ('glide %n secs to x:%n y:%n' #t #glideSecs:toX:y:elapsed:from: 1 50 50) #- ('change x by %n' #- #changeXposBy: 10) ('set x to %n' #- #xpos: 0) ('change y by %n' #- #changeYposBy: 10) ('set y to %n' #- #ypos: 0) #- ('if on edge, bounce' #- #bounceOffEdge) #- ('x position' #r #xpos) ('y position' #r #ypos) ('direction' #r #heading) 'pen' ('clear' #- #clearPenTrails) #- ('pen down' #- #putPenDown) ('pen up' #- #putPenUp) #- ('set pen color to %c' #- #penColor:) ('change pen color by %n' #- #changePenHueBy:) ('set pen color to %n' #- #setPenHueTo: 0) #- ('change pen shade by %n' #- #changePenShadeBy:) ('set pen shade to %n' #- #setPenShadeTo: 50) #- ('change pen size by %n' #- #changePenSizeBy: 1) ('set pen size to %n' #- #penSize: 1) #- ('stamp' #- #stampCostume) ). t1 _ t1 , #('looks' ('switch to costume %l' #- #lookLike:) ('next costume' #- #nextCostume) ('costume #' #r #costumeIndex) #- ('say %s for %n secs' #t #say:duration:elapsed:from: 'Hello!' 2) ('say %s' #- #say: 'Hello!') ('think %s for %n secs' #t #think:duration:elapsed:from: 'Hmm...' 2) ('think %s' #- #think: 'Hmm...') #- ('change %g effect by %n' #- #changeGraphicEffect:by: 'color' 25) ('set %g effect to %n' #- #setGraphicEffect:to: 'color' 0) ('clear graphic effects' #- #filterReset) #- ('change size by %n' #- #changeSizeBy:) ('set size to %n%' #- #setSizeTo: 100) ('size' #r #scale) #- ('show' #- #show) ('hide' #- #hide) #- ('go to front' #- #comeToFront) ('go back %n layers' #- #goBackByLayers: 1) 'sensing' ('touching %m?' #b #touching:) ('touching color %C?' #b #touchingColor:) ('color %C is touching %C?' #b #color:sees:) #- ('ask %s and wait' #s #doAsk 'What''s your name?') ('answer' #r #answer) #- ('mouse x' #r #mouseX) ('mouse y' #r #mouseY) ('mouse down?' #b #mousePressed) #- ('key %k pressed?' #b #keyPressed: 'space') #- ('distance to %m' #r #distanceTo:) #- ('reset timer' #- #timerReset) ('timer' #r #timer) #- ('%a of %m' #r #getAttribute:of:) #- #- ('loudness' #r #soundLevel) ('loud?' #b #isLoud) #~ ('%H sensor value' #r #sensor: 'slider') ('sensor %h?' #b #sensorPressed: 'button pressed') ). t1 _ t1 , NewBlocks. ^ t1 , super blockSpecs ! ! !ScratchSpriteMorph methodsFor: 'looks ops'! goFwdByLayers: t1 owner ifNil: [^ self]. self layer: (owner submorphs indexOf: self) - t1 truncated ! !
It gives me a Syntax Error message:
UndefinedObject as yet unclassified �
-------------------------------------------------------------------------------------------
<<<This string contains a character (ascii value 239) that is not normally used in code>>> �Nothing more expected ->��
Anyone want to try to fix that?
Last edited by scimonster (2011-09-08 10:39:41)
Offline
whizzer wrote:
Try my code? I don't know, I'll look up ascii 239.
EDIT: According to BYOB 3.1, ascii 239 is Ô.
That's what I got too, but there wasn't any of that in there.
Offline
Hmm, are there any symbols in there that aren't normally used?
Offline
ProgrammingFreak wrote:
Hmm, are there any symbols in there that aren't normally used?
No.
Offline
scimonster wrote:
ProgrammingFreak wrote:
Hmm, are there any symbols in there that aren't normally used?
No.
BTW, scimonster, Baderous found what you needed to view a method's content. See your thread.
Offline
Okay, so what exactly is this code supposed to do that it can't do because of this random error?
Offline
meowmeow55 wrote:
Okay, so what exactly is this code supposed to do that it can't do because of this random error?
I think I figured out the "random error". It was my encoding of the file — I was supposed to use UTF-8 but I used the default, ANSI. Is there any way to change the default character encoding in Notepad?
Offline
scimonster wrote:
meowmeow55 wrote:
Okay, so what exactly is this code supposed to do that it can't do because of this random error?
I think I figured out the "random error". It was my encoding of the file — I was supposed to use UTF-8 but I used the default, ANSI. Is there any way to change the default character encoding in Notepad?
There's a drop-down menu in the Save As windows that lets you set the encoding.
But still, what exactly does the code do?
Offline
meowmeow55 wrote:
scimonster wrote:
meowmeow55 wrote:
Okay, so what exactly is this code supposed to do that it can't do because of this random error?
I think I figured out the "random error". It was my encoding of the file — I was supposed to use UTF-8 but I used the default, ANSI. Is there any way to change the default character encoding in Notepad?
There's a drop-down menu in the Save As windows that lets you set the encoding.
But still, what exactly does the code do?
It should add the block code into a variable, which gets added to the blockspecs. Save and restart for it to work though.
Offline