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

#76 2012-04-22 03:46:08

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

Do you think it would work if I made an upload block function? It would send a form to the block library, requesting a certain block. The following would be filled in:

author
what the block does
category
whether it's for sprites or stage or all.
block spec
code
picture - possibly
block file.

You would right click a block with a selector labeled 'Upload Block'. Then it would show a dialog asking 'Upload block to the block library on the scratch forums?' , with yes or cancel. Clicking yes would prompt you for author name and what the block does. It would then show you a preview of the block, and verify that you want to upload it. The hard part (for me) is going to be how scratch would send some sort of message to block library with the block file, and the recently filled in forms, plus a picture.

Offline

 

#77 2012-04-22 04:04:11

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

Ok, now I'm going to start making the block files from all the scratch blocks in the library.

Offline

 

#78 2012-04-22 04:25:31

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Block Files

Hey! This is looking pretty cool, and you know, once you release the finished version the librarians will be able to help you convert all the blocks to the .blocks format. We'll have to host the files anyway, and 167 Scratch blocks is a lot to do by yourself!

As for the upload form, can I suggest you don't work on that quite yet? I agree it's a neat idea, but we haven't decided on a page name for our upload system, or indeed what information needs to be given for each block. You could probably send the information in the url using GET, though I know some people (like Magnie) have managed to get Scratch to post posts in the Scratch forums using POST values.

Block images will not have to be submitted, the idea is that a block renderer that is being written by nXIII at the moment will render your block based on your blockspec and category.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#79 2012-04-22 04:47:11

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

sparks wrote:

Hey! This is looking pretty cool, and you know, once you release the finished version the librarians will be able to help you convert all the blocks to the .blocks format. We'll have to host the files anyway, and 167 Scratch blocks is a lot to do by yourself!

As for the upload form, can I suggest you don't work on that quite yet? I agree it's a neat idea, but we haven't decided on a page name for our upload system, or indeed what information needs to be given for each block. You could probably send the information in the url using GET, though I know some people (like Magnie) have managed to get Scratch to post posts in the Scratch forums using POST values.

Block images will not have to be submitted, the idea is that a block renderer that is being written by nXIII at the moment will render your block based on your blockspec and category.

Ok, there are QUITE a lot of blocks in the block library. I've converted all the motion ones and some of the control ones. I haven't started on the upload form, but have considered it. NXII's block image renderer sounds pretty cool! I just fixed a few more bugs on the patch, by the way. I owe NXII a little credit for this block importer, just so you know.
I just can't wait for people to use the block importer, and blocks to be downloadable!
You will give credit, right?

p.s. Congratulations on becoming a Community Moderator! I would've voted for you if I could.

Offline

 

#80 2012-04-22 10:44:51

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

Re: Block Files

Is the "Create a Block" dialog supposed to be different between expert/non-expert modes?

Upon creating a block, a yellow Syntax Error window appears.  The method is ScriptableScratchMorph > blocks > defaultArgsFor:.  Here are the contents (the error is towards the bottom):

Code:

defaultArgsFor: t1 
    | t2 t3 t4 t5 t6 |
    t2 _ t1 copyFrom: 4 to: t1 size.
    t3 _ self ownerThatIsA: ScratchStageMorph.
    t4 _ (t1 at: 3) asSymbol.
    #gotoX:y: = t4 ifTrue: [t2 _ Array with: self referencePosition x rounded with: self referencePosition y rounded].
    #glideSecs:toX:y:elapsed:from: = t4 ifTrue: [t2 _ Array
                    with: 1
                    with: self referencePosition x rounded
                    with: self referencePosition y rounded].
    #motor:direction: = self ifTrue: [t2 _ Array
                    with: 'reverse' localized
                    with: 'this way' localized
                    with: 'that way'].
    #setSizeTo: = t4
        ifTrue: 
            [t5 _ (100.0 * (self scalePoint x max: self scalePoint y)) rounded.
            t2 _ Array with: t5].
    #getAttribute:of: = t4 ifTrue: [(t3 _ self ownerThatIsA: ScratchStageMorph) ifNil: [t2 _ Array with: 'x position' with: self]
            ifNotNil: 
                [t6 _ t3 submorphs select: [:t7 | t7 isKindOf: ScratchSpriteMorph].
                t6 sort: [:t8 :t9 | t8 objName asLowercase < t9 objName asLowercase].
                t6 size > 0
                    ifTrue: [t2 _ Array with: 'x position' with: t6 first]
                    ifFalse: [t2 _ Array with: 'background #' with: t3]]].
    #concatenate:with: = t4 ifTrue: [t2 _ Array with: 'hello ' localized with: 'world' localized].
    #doAsk = t4 ifTrue: [t2 _ Array with: 'What''s your name?' localized].
    #letter:of: = t4 ifTrue: [t2 _ Array with: 1 with: 'world' localized].
    #stringLength: = t4 ifTrue: [t2 _ Array with: 'world' localized].
    #say:duration:elapsed:from: = t4 ifTrue: [t2 _ Array with: 'Hello!' localized with: 2].
    #say: = t4 ifTrue: [t2 _ Array with: 'Hello!' localized].
    #think:duration:elapsed:from: = t4 ifTrue: [t2 _ Array with: 'Hmm...' localized with: 2].
    #think: = t4 ifTrue: [t2 _ Array with: 'Hmm...' localized].
    (#(#lookLike: #showBackground: ) includes: t4)
        ifTrue: [t2 _ Array with: self costumeNames last].
    (#(#playSound: #doPlaySoundAndWait ) includes: t4)
        ifTrue: 
            [t6 _ self soundNames.
            t2 _ t6 size <= 2
                        ifTrue: [Array with: '']
                        ifFalse: [Array with: (t6 at: t6 size - 2)]].
    (#(#broadcast: #doBroadcastAndWait ) includes: t4)
        ifTrue: [t3 ifNotNil: [t2 _ Array with: t3 defaultEventName]].
    (#(#append:toList: #deleteLine:ofList: #insert:at:ofList: ) includes: t4)
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: (t2 at: 1) localized]].
    (#(#append:toList: #deleteLine:ofList: #getLine:ofList: #insert:at:ofList: #lineCountOfList: ) includes: t4)
        ifTrue: [t2 _ t2 copyWith: self defaultListName].
    #setLine:ofList:to: = t4
        ifTrue: [t2 size >= 3
                ifTrue: 
                    [t2 at: 2 put: self defaultListName.
                    t2 at: 3 put: (t2 at: 3) localized]].
    #appendLettersOf:toList: = t4
        ifTrue: [t2 size >= 2
                ifTrue: 
                    [t2 at: 1 put: (t2 at: 1) localized.
                    t2 at: 2 put: self defaultListName]].
    #list:contains: = t4
        ifTrue: [t2 size >= 2
                ifTrue: 
                    [t2 at: 1 put: self defaultListName.
                    t2 at: 2 put: (t2 at: 2) loca#Period or right bracket expected ->selector = sel 
    ifTrue: [defaultArgs size >= 1 ifTrue: [defaultArgs at: 1 put: 'hello world' localized]]. ^ defaultArgs

Selecting "Save Blocks" produces "Squeak can not find the file C hmm .../SqueakV2.sources".  Then comes the blackscreen...   yikes

Creating an arg produces the error "Message not understood: letters:through:of:".

Also, could you provide up-to-date block and arg files for testing?

Last edited by Greenatic (2012-04-22 10:53:12)

Offline

 

#81 2012-04-22 11:17:31

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

Greenatic wrote:

Is the "Create a Block" dialog supposed to be different between expert/non-expert modes?

Upon creating a block, a yellow Syntax Error window appears.  The method is ScriptableScratchMorph > blocks > defaultArgsFor:.  Here are the contents (the error is towards the bottom):

Code:

defaultArgsFor: t1 
    | t2 t3 t4 t5 t6 |
    t2 _ t1 copyFrom: 4 to: t1 size.
    t3 _ self ownerThatIsA: ScratchStageMorph.
    t4 _ (t1 at: 3) asSymbol.
    #gotoX:y: = t4 ifTrue: [t2 _ Array with: self referencePosition x rounded with: self referencePosition y rounded].
    #glideSecs:toX:y:elapsed:from: = t4 ifTrue: [t2 _ Array
                    with: 1
                    with: self referencePosition x rounded
                    with: self referencePosition y rounded].
    #motor:direction: = self ifTrue: [t2 _ Array
                    with: 'reverse' localized
                    with: 'this way' localized
                    with: 'that way'].
    #setSizeTo: = t4
        ifTrue: 
            [t5 _ (100.0 * (self scalePoint x max: self scalePoint y)) rounded.
            t2 _ Array with: t5].
    #getAttribute:of: = t4 ifTrue: [(t3 _ self ownerThatIsA: ScratchStageMorph) ifNil: [t2 _ Array with: 'x position' with: self]
            ifNotNil: 
                [t6 _ t3 submorphs select: [:t7 | t7 isKindOf: ScratchSpriteMorph].
                t6 sort: [:t8 :t9 | t8 objName asLowercase < t9 objName asLowercase].
                t6 size > 0
                    ifTrue: [t2 _ Array with: 'x position' with: t6 first]
                    ifFalse: [t2 _ Array with: 'background #' with: t3]]].
    #concatenate:with: = t4 ifTrue: [t2 _ Array with: 'hello ' localized with: 'world' localized].
    #doAsk = t4 ifTrue: [t2 _ Array with: 'What''s your name?' localized].
    #letter:of: = t4 ifTrue: [t2 _ Array with: 1 with: 'world' localized].
    #stringLength: = t4 ifTrue: [t2 _ Array with: 'world' localized].
    #say:duration:elapsed:from: = t4 ifTrue: [t2 _ Array with: 'Hello!' localized with: 2].
    #say: = t4 ifTrue: [t2 _ Array with: 'Hello!' localized].
    #think:duration:elapsed:from: = t4 ifTrue: [t2 _ Array with: 'Hmm...' localized with: 2].
    #think: = t4 ifTrue: [t2 _ Array with: 'Hmm...' localized].
    (#(#lookLike: #showBackground: ) includes: t4)
        ifTrue: [t2 _ Array with: self costumeNames last].
    (#(#playSound: #doPlaySoundAndWait ) includes: t4)
        ifTrue: 
            [t6 _ self soundNames.
            t2 _ t6 size <= 2
                        ifTrue: [Array with: '']
                        ifFalse: [Array with: (t6 at: t6 size - 2)]].
    (#(#broadcast: #doBroadcastAndWait ) includes: t4)
        ifTrue: [t3 ifNotNil: [t2 _ Array with: t3 defaultEventName]].
    (#(#append:toList: #deleteLine:ofList: #insert:at:ofList: ) includes: t4)
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: (t2 at: 1) localized]].
    (#(#append:toList: #deleteLine:ofList: #getLine:ofList: #insert:at:ofList: #lineCountOfList: ) includes: t4)
        ifTrue: [t2 _ t2 copyWith: self defaultListName].
    #setLine:ofList:to: = t4
        ifTrue: [t2 size >= 3
                ifTrue: 
                    [t2 at: 2 put: self defaultListName.
                    t2 at: 3 put: (t2 at: 3) localized]].
    #appendLettersOf:toList: = t4
        ifTrue: [t2 size >= 2
                ifTrue: 
                    [t2 at: 1 put: (t2 at: 1) localized.
                    t2 at: 2 put: self defaultListName]].
    #list:contains: = t4
        ifTrue: [t2 size >= 2
                ifTrue: 
                    [t2 at: 1 put: self defaultListName.
                    t2 at: 2 put: (t2 at: 2) loca#Period or right bracket expected ->selector = sel 
    ifTrue: [defaultArgs size >= 1 ifTrue: [defaultArgs at: 1 put: 'hello world' localized]]. ^ defaultArgs

Selecting "Save Blocks" produces "Squeak can not find the file C hmm .../SqueakV2.sources".  Then comes the blackscreen...   yikes

Creating an arg produces the error "Message not understood: letters:through:of:".

Also, could you provide up-to-date block and arg files for testing?

Yes, the create a block dialog is supposed to be different. For less experienced all you need to do is enter text in the fields, with no selector required, it is automatically created from the message selector in the code. while in expert mode you type the full block spec include 'Sprites' (or 'Stage' or 'All') and the category name.

1st. I probably put a bad thing there. I'll fix it.

2nd. Save Blocks runs the code Smalltalk snapshot: true andQuit: false.
You need the changes and source file for this. Use the scratch source code.

3rd. A string operator must be missing. I forgot to file-out that.

4th. sure!

Offline

 

#82 2012-04-22 12:02:06

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

Re: Block Files

dreamod wrote:

Greenatic wrote:

Is the "Create a Block" dialog supposed to be different between expert/non-expert modes?

Upon creating a block, a yellow Syntax Error window appears.  The method is ScriptableScratchMorph > blocks > defaultArgsFor:.  Here are the contents (the error is towards the bottom):

Code:

defaultArgsFor: t1 
    | t2 t3 t4 t5 t6 |
    t2 _ t1 copyFrom: 4 to: t1 size.
    t3 _ self ownerThatIsA: ScratchStageMorph.
    t4 _ (t1 at: 3) asSymbol.
    #gotoX:y: = t4 ifTrue: [t2 _ Array with: self referencePosition x rounded with: self referencePosition y rounded].
    #glideSecs:toX:y:elapsed:from: = t4 ifTrue: [t2 _ Array
                    with: 1
                    with: self referencePosition x rounded
                    with: self referencePosition y rounded].
    #motor:direction: = self ifTrue: [t2 _ Array
                    with: 'reverse' localized
                    with: 'this way' localized
                    with: 'that way'].
    #setSizeTo: = t4
        ifTrue: 
            [t5 _ (100.0 * (self scalePoint x max: self scalePoint y)) rounded.
            t2 _ Array with: t5].
    #getAttribute:of: = t4 ifTrue: [(t3 _ self ownerThatIsA: ScratchStageMorph) ifNil: [t2 _ Array with: 'x position' with: self]
            ifNotNil: 
                [t6 _ t3 submorphs select: [:t7 | t7 isKindOf: ScratchSpriteMorph].
                t6 sort: [:t8 :t9 | t8 objName asLowercase < t9 objName asLowercase].
                t6 size > 0
                    ifTrue: [t2 _ Array with: 'x position' with: t6 first]
                    ifFalse: [t2 _ Array with: 'background #' with: t3]]].
    #concatenate:with: = t4 ifTrue: [t2 _ Array with: 'hello ' localized with: 'world' localized].
    #doAsk = t4 ifTrue: [t2 _ Array with: 'What''s your name?' localized].
    #letter:of: = t4 ifTrue: [t2 _ Array with: 1 with: 'world' localized].
    #stringLength: = t4 ifTrue: [t2 _ Array with: 'world' localized].
    #say:duration:elapsed:from: = t4 ifTrue: [t2 _ Array with: 'Hello!' localized with: 2].
    #say: = t4 ifTrue: [t2 _ Array with: 'Hello!' localized].
    #think:duration:elapsed:from: = t4 ifTrue: [t2 _ Array with: 'Hmm...' localized with: 2].
    #think: = t4 ifTrue: [t2 _ Array with: 'Hmm...' localized].
    (#(#lookLike: #showBackground: ) includes: t4)
        ifTrue: [t2 _ Array with: self costumeNames last].
    (#(#playSound: #doPlaySoundAndWait ) includes: t4)
        ifTrue: 
            [t6 _ self soundNames.
            t2 _ t6 size <= 2
                        ifTrue: [Array with: '']
                        ifFalse: [Array with: (t6 at: t6 size - 2)]].
    (#(#broadcast: #doBroadcastAndWait ) includes: t4)
        ifTrue: [t3 ifNotNil: [t2 _ Array with: t3 defaultEventName]].
    (#(#append:toList: #deleteLine:ofList: #insert:at:ofList: ) includes: t4)
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: (t2 at: 1) localized]].
    (#(#append:toList: #deleteLine:ofList: #getLine:ofList: #insert:at:ofList: #lineCountOfList: ) includes: t4)
        ifTrue: [t2 _ t2 copyWith: self defaultListName].
    #setLine:ofList:to: = t4
        ifTrue: [t2 size >= 3
                ifTrue: 
                    [t2 at: 2 put: self defaultListName.
                    t2 at: 3 put: (t2 at: 3) localized]].
    #appendLettersOf:toList: = t4
        ifTrue: [t2 size >= 2
                ifTrue: 
                    [t2 at: 1 put: (t2 at: 1) localized.
                    t2 at: 2 put: self defaultListName]].
    #list:contains: = t4
        ifTrue: [t2 size >= 2
                ifTrue: 
                    [t2 at: 1 put: self defaultListName.
                    t2 at: 2 put: (t2 at: 2) loca#Period or right bracket expected ->selector = sel 
    ifTrue: [defaultArgs size >= 1 ifTrue: [defaultArgs at: 1 put: 'hello world' localized]]. ^ defaultArgs

Selecting "Save Blocks" produces "Squeak can not find the file C hmm .../SqueakV2.sources".  Then comes the blackscreen...   yikes

Creating an arg produces the error "Message not understood: letters:through:of:".

Also, could you provide up-to-date block and arg files for testing?

Yes, the create a block dialog is supposed to be different. For less experienced all you need to do is enter text in the fields, with no selector required, it is automatically created from the message selector in the code. while in expert mode you type the full block spec include 'Sprites' (or 'Stage' or 'All') and the category name.

1st. I probably put a bad thing there. I'll fix it.

2nd. Save Blocks runs the code Smalltalk snapshot: true andQuit: false.
You need the changes and source file for this. Use the scratch source code.

3rd. A string operator must be missing. I forgot to file-out that.

4th. sure!

2nd.  Never mind, that glitch only happens with fill screen off...but what is it supposed to do?  Close Scratch?  It's not doing that...

Offline

 

#83 2012-04-22 13:10:31

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Block Files

Firstly, thanks dreamod, It's nice to know you would have voted for me if you could!

Secondly, while I was at work today, I was thinking about what you said about block build forms in Scratch that could upload a block directly and I had an idea. A possibly trick idea, but I thought I would share it with you.

The main problem with block sharing at the moment is that people submit blocks either in the wrong format (missing spec or code) or they just haven't tested it. Rather than a menu-form, how possible to do you think it would be to add a "share this block" option to the right-click menu of blocks (next to duplicate, delete etc)? This would hopefully mean that the block has been made and tested by the user before it was sent off.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#84 2012-04-22 15:04:42

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

Greenatic wrote:

dreamod wrote:

Greenatic wrote:

Is the "Create a Block" dialog supposed to be different between expert/non-expert modes?

Upon creating a block, a yellow Syntax Error window appears.  The method is ScriptableScratchMorph > blocks > defaultArgsFor:.  Here are the contents (the error is towards the bottom):

Code:

defaultArgsFor: t1 
    | t2 t3 t4 t5 t6 |
    t2 _ t1 copyFrom: 4 to: t1 size.
    t3 _ self ownerThatIsA: ScratchStageMorph.
    t4 _ (t1 at: 3) asSymbol.
    #gotoX:y: = t4 ifTrue: [t2 _ Array with: self referencePosition x rounded with: self referencePosition y rounded].
    #glideSecs:toX:y:elapsed:from: = t4 ifTrue: [t2 _ Array
                    with: 1
                    with: self referencePosition x rounded
                    with: self referencePosition y rounded].
    #motor:direction: = self ifTrue: [t2 _ Array
                    with: 'reverse' localized
                    with: 'this way' localized
                    with: 'that way'].
    #setSizeTo: = t4
        ifTrue: 
            [t5 _ (100.0 * (self scalePoint x max: self scalePoint y)) rounded.
            t2 _ Array with: t5].
    #getAttribute:of: = t4 ifTrue: [(t3 _ self ownerThatIsA: ScratchStageMorph) ifNil: [t2 _ Array with: 'x position' with: self]
            ifNotNil: 
                [t6 _ t3 submorphs select: [:t7 | t7 isKindOf: ScratchSpriteMorph].
                t6 sort: [:t8 :t9 | t8 objName asLowercase < t9 objName asLowercase].
                t6 size > 0
                    ifTrue: [t2 _ Array with: 'x position' with: t6 first]
                    ifFalse: [t2 _ Array with: 'background #' with: t3]]].
    #concatenate:with: = t4 ifTrue: [t2 _ Array with: 'hello ' localized with: 'world' localized].
    #doAsk = t4 ifTrue: [t2 _ Array with: 'What''s your name?' localized].
    #letter:of: = t4 ifTrue: [t2 _ Array with: 1 with: 'world' localized].
    #stringLength: = t4 ifTrue: [t2 _ Array with: 'world' localized].
    #say:duration:elapsed:from: = t4 ifTrue: [t2 _ Array with: 'Hello!' localized with: 2].
    #say: = t4 ifTrue: [t2 _ Array with: 'Hello!' localized].
    #think:duration:elapsed:from: = t4 ifTrue: [t2 _ Array with: 'Hmm...' localized with: 2].
    #think: = t4 ifTrue: [t2 _ Array with: 'Hmm...' localized].
    (#(#lookLike: #showBackground: ) includes: t4)
        ifTrue: [t2 _ Array with: self costumeNames last].
    (#(#playSound: #doPlaySoundAndWait ) includes: t4)
        ifTrue: 
            [t6 _ self soundNames.
            t2 _ t6 size <= 2
                        ifTrue: [Array with: '']
                        ifFalse: [Array with: (t6 at: t6 size - 2)]].
    (#(#broadcast: #doBroadcastAndWait ) includes: t4)
        ifTrue: [t3 ifNotNil: [t2 _ Array with: t3 defaultEventName]].
    (#(#append:toList: #deleteLine:ofList: #insert:at:ofList: ) includes: t4)
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: (t2 at: 1) localized]].
    (#(#append:toList: #deleteLine:ofList: #getLine:ofList: #insert:at:ofList: #lineCountOfList: ) includes: t4)
        ifTrue: [t2 _ t2 copyWith: self defaultListName].
    #setLine:ofList:to: = t4
        ifTrue: [t2 size >= 3
                ifTrue: 
                    [t2 at: 2 put: self defaultListName.
                    t2 at: 3 put: (t2 at: 3) localized]].
    #appendLettersOf:toList: = t4
        ifTrue: [t2 size >= 2
                ifTrue: 
                    [t2 at: 1 put: (t2 at: 1) localized.
                    t2 at: 2 put: self defaultListName]].
    #list:contains: = t4
        ifTrue: [t2 size >= 2
                ifTrue: 
                    [t2 at: 1 put: self defaultListName.
                    t2 at: 2 put: (t2 at: 2) loca#Period or right bracket expected ->selector = sel 
    ifTrue: [defaultArgs size >= 1 ifTrue: [defaultArgs at: 1 put: 'hello world' localized]]. ^ defaultArgs

Selecting "Save Blocks" produces "Squeak can not find the file C hmm .../SqueakV2.sources".  Then comes the blackscreen...   yikes

Creating an arg produces the error "Message not understood: letters:through:of:".

Also, could you provide up-to-date block and arg files for testing?

Yes, the create a block dialog is supposed to be different. For less experienced all you need to do is enter text in the fields, with no selector required, it is automatically created from the message selector in the code. while in expert mode you type the full block spec include 'Sprites' (or 'Stage' or 'All') and the category name.

1st. I probably put a bad thing there. I'll fix it.

2nd. Save Blocks runs the code Smalltalk snapshot: true andQuit: false.
You need the changes and source file for this. Use the scratch source code.

3rd. A string operator must be missing. I forgot to file-out that.

4th. sure!

2nd.  Never mind, that glitch only happens with fill screen off...but what is it supposed to do?  Close Scratch?  It's not doing that...

It saves the image without closing scratch.
Smalltalk snapshot: true (save) andQuit: false (don't quit)

Offline

 

#85 2012-04-22 15:09:37

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

sparks wrote:

Firstly, thanks dreamod, It's nice to know you would have voted for me if you could!

Secondly, while I was at work today, I was thinking about what you said about block build forms in Scratch that could upload a block directly and I had an idea. A possibly trick idea, but I thought I would share it with you.

The main problem with block sharing at the moment is that people submit blocks either in the wrong format (missing spec or code) or they just haven't tested it. Rather than a menu-form, how possible to do you think it would be to add a "share this block" option to the right-click menu of blocks (next to duplicate, delete etc)? This would hopefully mean that the block has been made and tested by the user before it was sent off.

That's exactly what I was thinking, and when you select that option, it asks for your account name and a comment, the rest is automatic. I have an export method, and I would just have to modify it so it exports to the block library. The part that I'm not so sure about is how I would make it automatically send the file to the block library.

Offline

 

#86 2012-04-22 15:19:04

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

dreamod wrote:

Greenatic wrote:

dreamod wrote:

Yes, the create a block dialog is supposed to be different. For less experienced all you need to do is enter text in the fields, with no selector required, it is automatically created from the message selector in the code. while in expert mode you type the full block spec include 'Sprites' (or 'Stage' or 'All') and the category name.

1st. I probably put a bad thing there. I'll fix it.

2nd. Save Blocks runs the code Smalltalk snapshot: true andQuit: false.
You need the changes and source file for this. Use the scratch source code.

3rd. A string operator must be missing. I forgot to file-out that.

4th. sure!

2nd.  Never mind, that glitch only happens with fill screen off...but what is it supposed to do?  Close Scratch?  It's not doing that...

It saves the image without closing scratch.
Smalltalk snapshot: true (save) andQuit: false (don't quit)

I updated the patch, and the errors are fixed.
Here is a download link to the set rotation style block, with the arg.

http://www.freefilehosting.net/setrotationstyletor

Try importing that one, it should work.

Offline

 

#87 2012-04-22 16:22:03

rookwood101
Scratcher
Registered: 2011-07-29
Posts: 500+

Re: Block Files

Where can we download the latest version of the patch?


http://i.imgur.com/zeIZW.png

Offline

 

#88 2012-04-22 16:48:46

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Block Files

dreamod wrote:

That's exactly what I was thinking, and when you select that option, it asks for your account name and a comment, the rest is automatic. I have an export method, and I would just have to modify it so it exports to the block library. The part that I'm not so sure about is how I would make it automatically send the file to the block library.

Cool! That sounds terrific! I had a look at the limits of GET value lengths, and apparently there aren't any, but it's a good idea to stay 255 bytes. If the string is too long for the server to handle, a 414 error is displayed. So you could try this (excuse my terrible smalltalk skills):

Code:

self readFromUrl: "http://www.blocks.scratchr.org/blockSubmissionAPI.php?user=", username, "&password=", password, "&fileContents=", fileContents.

It's just an example, but hopefully you can see how this would work. The only problem maybe is that the password is not encrypted during sending... Providing the file contents isn't too big, it should work. The receiving PHP file will get the information sent to it in the URL and then create a new .block file, kept in the moderator area of the site until it is approved by a mod as safe at which point it will become available on the site.


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#89 2012-04-22 19:13:01

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

Re: Block Files

Attempting to download the block from the URL you posted made Scratch run super-slow.

EDIT:  Another "Syntax Error" box.  Same trigger as before.  Contents below.

Code:

defaultArgsFor: t1 
    | t2 t3 t4 t5 t6 |
    t2 _ t1 copyFrom: 4 to: t1 size.
    t3 _ self ownerThatIsA: ScratchStageMorph.
    t4 _ (t1 at: 3) asSymbol.
    #gotoX:y: = t4 ifTrue: [t2 _ Array with: self referencePosition x rounded with: self referencePosition y rounded].
    #glideSecs:toX:y:elapsed:from: = t4 ifTrue: [t2 _ Array
                    with: 1
                    with: self referencePosition x rounded
                    with: self referencePosition y rounded].
    #motor:direction: = self ifTrue: [t2 _ Array
                    with: 'reverse' localized
                    with: 'this way' localized
                    with: 'that way'].
    #setSizeTo: = t4
        ifTrue: 
            [t5 _ (100.0 * (self scalePoint x max: self scalePoint y)) rounded.
            t2 _ Array with: t5].
    #getAttribute:of: = t4 ifTrue: [(t3 _ self ownerThatIsA: ScratchStageMorph) ifNil: [t2 _ Array with: 'x position' with: self]
            ifNotNil: 
                [t6 _ t3 submorphs select: [:t7 | t7 isKindOf: ScratchSpriteMorph].
                t6 sort: [:t8 :t9 | t8 objName asLowercase < t9 objName asLowercase].
                t6 size > 0
                    ifTrue: [t2 _ Array with: 'x position' with: t6 first]
                    ifFalse: [t2 _ Array with: 'background #' with: t3]]].
    #concatenate:with: = t4 ifTrue: [t2 _ Array with: 'hello ' localized with: 'world' localized].
    #doAsk = t4 ifTrue: [t2 _ Array with: 'What''s your name?' localized].
    #letter:of: = t4 ifTrue: [t2 _ Array with: 1 with: 'world' localized].
    #stringLength: = t4 ifTrue: [t2 _ Array with: 'world' localized].
    #say:duration:elapsed:from: = t4 ifTrue: [t2 _ Array with: 'Hello!' localized with: 2].
    #say: = t4 ifTrue: [t2 _ Array with: 'Hello!' localized].
    #think:duration:elapsed:from: = t4 ifTrue: [t2 _ Array with: 'Hmm...' localized with: 2].
    #think: = t4 ifTrue: [t2 _ Array with: 'Hmm...' localized].
    (#(#lookLike: #showBackground: ) includes: t4)
        ifTrue: [t2 _ Array with: self costumeNames last].
    (#(#playSound: #doPlaySoundAndWait ) includes: t4)
        ifTrue: 
            [t6 _ self soundNames.
            t2 _ t6 size <= 2
                        ifTrue: [Array with: '']
                        ifFalse: [Array with: (t6 at: t6 size - 2)]].
    (#(#broadcast: #doBroadcastAndWait ) includes: t4)
        ifTrue: [t3 ifNotNil: [t2 _ Array with: t3 defaultEventName]].
    (#(#append:toList: #deleteLine:ofList: #insert:at:ofList: ) includes: t4)
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: (t2 at: 1) localized]].
    (#(#append:toList: #deleteLine:ofList: #getLine:ofList: #insert:at:ofList: #lineCountOfList: ) includes: t4)
        ifTrue: [t2 _ t2 copyWith: self defaultListName].
    #setLine:ofList:to: = t4
        ifTrue: [t2 size >= 3
                ifTrue: 
                    [t2 at: 2 put: self defaultListName.
                    t2 at: 3 put: (t2 at: 3) localized]].
    #appendLettersOf:toList: = t4
        ifTrue: [t2 size >= 2
                ifTrue: 
                    [t2 at: 1 put: (t2 at: 1) localized.
                    t2 at: 2 put: self defaultListName]].
    #list:contains: = t4
        ifTrue: [t2 size >= 2
                ifTrue: 
                    [t2 at: 1 put: self defaultListName.
                    t2 at: 2 put: (t2 at: 2) localized]].
    #selector = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: 'hello world' loca#Period or right bracket expected ->selector = sel 
    ifTrue: [defaultArgs size >= 1 ifTrue: [defaultArgs at: 1 put: 'hello world' localized]]. ^ defaultArgs

Last edited by Greenatic (2012-04-22 19:15:38)

Offline

 

#90 2012-04-22 19:19:43

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

Re: Block Files

Which should I do?
Where should it go?


Get ready for domination of:  tongue

Offline

 

#91 2012-04-22 19:38:34

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Block Files

Has anyone given any thought to custom argument names? Scratch's arguments can be named %a-%z, %A-%Z, which is only 52 arguments, 24 of which are already in use, which if my terrible maths skills are correct, means that there are only 28 argument letters left for our use... This is why we used $Words$ rather than %l (letters) in Panther  tongue


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#92 2012-04-23 01:24:30

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

rookwood101 wrote:

Where can we download the latest version of the patch?

It's on my project 'Block Importer 2.0'

Offline

 

#93 2012-04-23 01:30:22

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

sparks wrote:

Has anyone given any thought to custom argument names? Scratch's arguments can be named %a-%z, %A-%Z, which is only 52 arguments, 24 of which are already in use, which if my terrible maths skills are correct, means that there are only 28 argument letters left for our use... This is why we used $Words$ rather than %l (letters) in Panther  tongue

Oh, yeah. I've always loved that system. You are part of the panther development team, correct? So... could you make a patch with all the methods used to make that possible? Or give me permission to use that system? I would have a sort of arg converter too! So that if you import a block with a bad arg, it converts it to a valid arg (ex %m to $Sprite$ or %b to $Boolean$, or if none is found, the $String$ arg. So... good idea? The panther team will get credit.

Offline

 

#94 2012-04-23 01:35:53

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

sparks wrote:

dreamod wrote:

That's exactly what I was thinking, and when you select that option, it asks for your account name and a comment, the rest is automatic. I have an export method, and I would just have to modify it so it exports to the block library. The part that I'm not so sure about is how I would make it automatically send the file to the block library.

Cool! That sounds terrific! I had a look at the limits of GET value lengths, and apparently there aren't any, but it's a good idea to stay 255 bytes. If the string is too long for the server to handle, a 414 error is displayed. So you could try this (excuse my terrible smalltalk skills):

Code:

self readFromUrl: "http://www.blocks.scratchr.org/blockSubmissionAPI.php?user=", username, "&password=", password, "&fileContents=", fileContents.

It's just an example, but hopefully you can see how this would work. The only problem maybe is that the password is not encrypted during sending... Providing the file contents isn't too big, it should work. The receiving PHP file will get the information sent to it in the URL and then create a new .block file, kept in the moderator area of the site until it is approved by a mod as safe at which point it will become available on the site.

Ok, I'm pretty good at squeak, but I don't know a lot about SQL and php, I have web blox though.  smile .
Anyway, I don't know about '&fileContents='. One point about block files, is it's not only easy to handle but can be really huge without taking up much space, that's why there is a 'moreCodes' feature, which lets you file-out codes from other places in the source code, or 'customCodes' which let's you file-out your own codes. Would the contents of the file be in the url? How did the scratch team make uploading scratch projects possible?

Offline

 

#95 2012-04-23 05:35:59

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Block Files

dreamod wrote:

Anyway, I don't know about '&fileContents='. One point about block files, is it's not only easy to handle but can be really huge without taking up much space, that's why there is a 'moreCodes' feature, which lets you file-out codes from other places in the source code, or 'customCodes' which let's you file-out your own codes. Would the contents of the file be in the url? How did the scratch team make uploading scratch projects possible?

I think you probably want to use an HTTP POST, not a GET; though how you'd do this within Squeak I'm not sure  tongue 
POSTs are more suited for uploading files, etc.

This is what Scratch uses for uploading; and from looking at the code briefly just now, it looks like they're implementing their own code for sending the HTTP protocol.

Hope that helps...  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#96 2012-04-23 05:39:36

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Block Files

I do a lot of work with web languages, so I can sort out the non-squeak side of things. As blob8108 points out above, the HTTP POST method is much better for files, I only suggested GET because I don't know how to get Panther to POST. However, Magnie does, so I'll drop him a message and see if he will come over and give us a hand with this part  smile

When the moreCodes feature is use to make a block, will the block still be exportable and importable as the one file?


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#97 2012-04-23 09:30:18

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Block Files

sparks wrote:

I do a lot of work with web languages, so I can sort out the non-squeak side of things. As blob8108 points out above, the HTTP POST method is much better for files, I only suggested GET because I don't know how to get Panther to POST. However, Magnie does, so I'll drop him a message and see if he will come over and give us a hand with this part  smile

When the moreCodes feature is use to make a block, will the block still be exportable and importable as the one file?

Actually, I have no idea how to use HTTP POST. I don't even know any Squeak.  tongue

But if I know my my HTTP protocol enough, I believe it's part of the request.
A get request looks like this:

Code:

GET /index.html?userid=joe&password=guessme HTTP/1.1
Host: www.mysite.com
User-Agent: Mozilla/4.0

A post request looks like this:

Code:

POST /login.jsp HTTP/1.1
Host: www.mysite.com
User-Agent: Mozilla/4.0
Content-Length: 27
Content-Type: application/x-www-form-urlencoded

userid=joe&password=guessme

Or at least that's what I've found looking at the HTTP Protocol.  tongue  Not sure if it will help, but I hope it does.  smile

Got the code from here: http://developers.sun.com/mobility/midp/ttips/HTTPPost/

Last edited by Magnie (2012-04-23 09:31:10)

Offline

 

#98 2012-04-23 10:02:10

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

sparks wrote:

I do a lot of work with web languages, so I can sort out the non-squeak side of things. As blob8108 points out above, the HTTP POST method is much better for files, I only suggested GET because I don't know how to get Panther to POST. However, Magnie does, so I'll drop him a message and see if he will come over and give us a hand with this part  smile

When the moreCodes feature is use to make a block, will the block still be exportable and importable as the one file?

Yes, the block file is basically a special patch, and the moreCodes adds to the block file.

Offline

 

#99 2012-04-23 10:07:10

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: Block Files

Oops, sorry Magnie! I thought it was you who did that... Thanks for the help though  smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#100 2012-04-23 10:10:03

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: Block Files

sparks wrote:

Oops, sorry Magnie! I thought it was you who did that... Thanks for the help though  smile

I'm not good at interfering with the internet in programming, but if a request gets sent, let's say POST, what happens then?

Offline

 

Board footer