This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#26 2011-08-14 23:51:25

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Developing BLOCK files.

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

 

#27 2011-08-24 15:18:59

IHeartGaming
Scratcher
Registered: 2010-07-23
Posts: 1000+

Re: Developing BLOCK files.

I really want this!


IHeartGaming

Offline

 

#28 2011-09-05 06:03:52

origami3
Scratcher
Registered: 2011-08-11
Posts: 28

Re: Developing BLOCK files.

could I help I love Making New blocks In scratch and BYOB
Whit should I do To start?


I am awesome

Offline

 

#29 2011-09-05 06:21:51

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Developing BLOCK files.

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

 

#30 2011-09-05 09:11:17

origami3
Scratcher
Registered: 2011-08-11
Posts: 28

Re: Developing BLOCK files.

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


I am awesome

Offline

 

#31 2011-09-05 09:49:58

fuz50
Scratcher
Registered: 2008-09-19
Posts: 100+

Re: Developing BLOCK files.

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?  smile


http://img10.imageshack.us/img10/7404/cooltext529102298.jpg
http://siggen.toontown-click.de/sig1.pnghttp://siggen.toontown-click.de/sig2.png

Offline

 

#32 2011-09-05 12:11:44

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Developing BLOCK files.

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?  smile

Well, I was going to do it in Notepad and just save with the extension .block.

Offline

 

#33 2011-09-05 12:52:02

origami3
Scratcher
Registered: 2011-08-11
Posts: 28

Re: Developing BLOCK files.

I am Confused on how to put the picture on Can you help me


I am awesome

Offline

 

#34 2011-09-05 13:27:51

whizzer
Scratcher
Registered: 2008-05-27
Posts: 500+

Re: Developing BLOCK files.

Code:

'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.


http://i46.tinypic.com/33df6me.png I'm whizzer0 for all things Minecraft.

Offline

 

#35 2011-09-05 13:56:59

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Developing BLOCK files.

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

 

#36 2011-09-07 12:57:26

whizzer
Scratcher
Registered: 2008-05-27
Posts: 500+

Re: Developing BLOCK files.

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.


http://i46.tinypic.com/33df6me.png I'm whizzer0 for all things Minecraft.

Offline

 

#37 2011-09-07 13:29:52

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Developing BLOCK files.

I'm working on something that uses the installer to create variables, and from there it will work.  smile

Offline

 

#38 2011-09-07 14:26:07

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Developing BLOCK files.

I would help but i don't know anything about squeak D:


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#39 2011-09-07 14:27:06

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Developing BLOCK files.

Can't wait till this is done.  big_smile

Offline

 

#40 2011-09-08 10:38:59

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Developing BLOCK files.

So here's what I've tried so far.
I save the following code as "test.block" and try to import it.

Code:

'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

 

#41 2011-09-08 13:29:52

whizzer
Scratcher
Registered: 2008-05-27
Posts: 500+

Re: Developing BLOCK files.

Try my code? I don't know, I'll look up ascii 239.
EDIT: According to BYOB 3.1, ascii 239 is Ô.

Last edited by whizzer (2011-09-08 13:31:40)


http://i46.tinypic.com/33df6me.png I'm whizzer0 for all things Minecraft.

Offline

 

#42 2011-09-08 13:40:40

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Developing BLOCK files.

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.  hmm

Offline

 

#43 2011-09-08 13:42:29

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Developing BLOCK files.

Hmm, are there any symbols in there that aren't normally used?  hmm

Offline

 

#44 2011-09-08 13:45:59

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Developing BLOCK files.

ProgrammingFreak wrote:

Hmm, are there any symbols in there that aren't normally used?  hmm

No.

Offline

 

#45 2011-09-08 16:37:12

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Developing BLOCK files.

scimonster wrote:

ProgrammingFreak wrote:

Hmm, are there any symbols in there that aren't normally used?  hmm

No.

BTW, scimonster, Baderous found what you needed to view a method's content.  See your thread.

Offline

 

#46 2011-09-16 19:26:32

meowmeow55
Scratcher
Registered: 2008-12-24
Posts: 1000+

Re: Developing BLOCK files.

Okay, so what exactly is this code supposed to do that it can't do because of this random error?


Yawn.

Offline

 

#47 2011-09-17 13:50:58

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Developing BLOCK files.

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

 

#48 2011-09-17 13:56:44

meowmeow55
Scratcher
Registered: 2008-12-24
Posts: 1000+

Re: Developing BLOCK files.

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?


Yawn.

Offline

 

#49 2011-09-17 14:08:46

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Developing BLOCK files.

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

 

#50 2011-11-15 23:07:10

SuperJedi224
Scratcher
Registered: 2010-12-22
Posts: 23

Re: Developing BLOCK files.

So how do you add new blcks in squeak?


http://internetometer.com/image/30818.png

Offline

 

Board footer