After working a couple hours with the source code, I finally managed to develop a completely automatic feature to convert your graphical blocks to forum block code, within your Scratch program!
To install, download the plugin here and install it by filing it in (see my next post on this thread for instructions). Please note that if you have made previous changes to the blocks' right click menu, you must pay extreme care as to avoid overriding your menu! All other code is new however and there are no risks in installing this.
To use, right click on any block in the scripting pane (so drag 'em out of the palette first) and select "export as scratchblocks". The code of that block plus all blocks below it (as with the duplicate function) will be automatically copied to your clipboard!
Please note this is experimental. Although I have tested all blocks on the forums, there may be some bug I did not spot. Therefore, if you experience any kind of problem on your system, please tell me below.
I must remind you not to spam the forums with blocks, so keep the testing to this thread if you really must, but have fun using the plugin!
Offline
HOW TO INSTALL THE FILE ABOVE
First of all, if the link above took you to text inside a webpage, save that webpage as a CS file or copy the text into your text editor and then save it as a CS file.
Now, open Scratch.
Now, turn fill screen off. If you are on a normal Scratch, this is done with Shift-Click-R.
Then open the file browser (click on the black space, open, file list).
Navigate to the file you just downloaded. Right click it and select fileIn.
Have fun!
Last edited by LS97 (2012-07-26 04:27:00)
Offline
Cool, I'm excited to try it out!
Offline
Updated the instructions, if that's what held you back
Offline
Oh, cool! This is like my TBG Blocks plugin!
EDIT: oh, that's what it does... I thought it generated a scratchBlocksPlugin with your new blocks included.
Last edited by GeonoTRON2000 (2012-07-22 15:25:03)
Offline
Very nice! I tested this with the block list and block plugin tester I used for testing Kurt. Everything worked except for the "broadcast" and "broadcast and wait" blocks, which omit the message.
Offline
blob8108 wrote:
Very nice! I tested this with the block list and block plugin tester I used for testing Kurt. Everything worked except for the "broadcast" and "broadcast and wait" blocks, which omit the message.
Ah, of course they do, they use a type of argument that isn't one I handled! I shall fix this when I have time
Offline
(t1 isKindOf: EventTitleMorph) ifTrue: [t2 nextPut: $[. t2 nextPutAll: t1 eventName. t2 nextPutAll: ' v]'].
— seems to do it. But I don't claim to be any good at Squeak.
Including "Scratchblocks code generated using plugin by LS97" with each exported thing is really annoying...
Offline
This is pretty cool!
when I receive [StartGame v] set [XVelocity v] to [0] set [YVelocity v] to [0] broadcast broadcast and wait show switch to costume [normal v] go to front forever set [Gravity v] to [0.2] switch to costume [sense v] if <color [#00FF52] is touching [#000001]?> set [YVelocity v] to [-0.2] end if <color [#FF0000] is touching [#000001]?> set [XVelocity v] to [-0.2] end if <color [#0042FF] is touching [#000001]?> set [XVelocity v] to [0.2] end if <color [#FF0000] is touching [#FF9500]?> if <key [space v] pressed?> set [XVelocity v] to [-3] set [YVelocity v] to [2] end end if <color [#0042FF] is touching [#FF9500]?> if <key [space v] pressed?> set [XVelocity v] to [3] set [YVelocity v] to [2] end end if <color [#006363] is touching [#000001]?> set [YVelocity v] to [1] change y by (YVelocity) end if <color [#630000] is touching [#000001]?> set [YVelocity v] to [-1] end if <color [#636300] is touching [#000001]?> set [XVelocity v] to [1] end if <color [#CE7300] is touching [#000001]?> set [XVelocity v] to [-1] end if <not <color [#8400FF] is touching [#000001]?>> change [YVelocity v] by (join [-] (Gravity)) change y by (YVelocity) end if <color [#8400FF] is touching [#000001]?> if <(YVelocity) < [-5]> set [XVelocity v] to [0] set [YVelocity v] to [0] broadcast and wait broadcast and wait end set [YVelocity v] to [0] if <key [space v] pressed?> if <touching color [#FF9500]?> set [YVelocity v] to [4] else set [YVelocity v] to [2] end end end if <not <<key [a v] pressed?> or <key [d v] pressed?>>> switch to costume [normal v] end if <key [d v] pressed?> switch to costume [lookright v] if <touching color [#00CC44]?> change [XVelocity v] by (0.3) else if <(XVelocity) < [5]> change [XVelocity v] by (0.1) end end end if <key [a v] pressed?> switch to costume [lookleft v] if <touching color [#00CC44]?> change [XVelocity v] by (-0.3) else if <(XVelocity) > [-5]> change [XVelocity v] by (-0.1) end end end set [XVelocity v] to ((XVelocity) * (0.95)) change y by (YVelocity) change x by (XVelocity) if <key [w v] pressed?> if <touching [door v]?> broadcast and wait change [Level v] by (1) set [XVelocity v] to [0] set [YVelocity v] to [0] broadcast broadcast and wait end end if <touching color [#FFFF00]?> set [XVelocity v] to [0] set [YVelocity v] to [0] broadcast and wait broadcast and wait end if <touching [pain v]?> set [XVelocity v] to [0] set [YVelocity v] to [0] broadcast and wait broadcast and wait end end
Offline
You should make one that imports scratchblocks code into scratch!
Offline
daniel_j wrote:
Eh, this is going to sound sooo noobish, but where is the clipboard? xD I'm use to text based languages and I just don't get scratch xD
The clipboard is where stuff goes when you use copy/paste. Right click, choose "export scratchblocks", and then just right click in the forum "post" box and choose "paste".
Offline
samtwheels wrote:
You should make one that imports scratchblocks code into scratch!
Again, I'm working on exactly that in Python. It's quite complicated; a bit like writing a parser/compiler. The hardest part is dealing with booleans, because the less than/greater than symbol looks like the beginning/end of a boolean block:
if <(2)>(3)>
I've managed to deal with this by learning how proper parsers work, though.
Last edited by blob8108 (2012-07-23 05:34:23)
Offline
blob8108 wrote:
Code:
(t1 isKindOf: EventTitleMorph) ifTrue: [t2 nextPut: $[. t2 nextPutAll: t1 eventName. t2 nextPutAll: ' v]'].— seems to do it. But I don't claim to be any good at Squeak.
Including "Scratchblocks code generated using plugin by LS97" with each exported thing is really annoying...
It probably can do it, I shall update soon! Promise!
And yeah, sorry, I'll remove the text in the next update.
Offline
Updated!
Fixed broadcasts and removed credit text.
Offline
Wow this is awesome! I tried to download it before but my chrome didn't want to show it's Save As dialogue box... And it was acting strange and flash kept crashing and so did some tabs. It works fine now though.
Offline
LS97 wrote:
Updated!
Fixed broadcasts and removed credit text.
Cool! Adding the "copied to clipboard" message was a good idea, too. The first time I used your plugin I thought nothing had happened
It could get slightly annoying, though — perhaps add an option to disable it?
Offline
blob8108 wrote:
LS97 wrote:
Updated!
Fixed broadcasts and removed credit text.Cool! Adding the "copied to clipboard" message was a good idea, too. The first time I used your plugin I thought nothing had happened
It could get slightly annoying, though — perhaps add an option to disable it?
Oh come on, I'm on holiday...
Offline
LS97 wrote:
Oh come on, I'm on holiday...
...you mean you don't do this for fun?
Offline
blob8108 wrote:
LS97 wrote:
Oh come on, I'm on holiday...
...you mean you don't do this for fun?
Of course I do, otherwise I wouldn't have done it in the first place
But it goes without saying that I prefer a swim in the pool or a day at the beach...
Offline