Discuss Scratch
- Discussion Forums
- » Open Source Projects
- » How to get Scratch to JavaScript? Support us now!
- sausagescratch
-
78 posts
How to get Scratch to JavaScript? Support us now!
-
Last edited by sausagescratch (Jan. 17, 2021 12:32:59)
- ilovericebubbles
-
100+ posts
How to get Scratch to JavaScript? Support us now!
outside of Scratch!You would probably have to credit Scratch, but nice Idea! you could then change any parts you want and you'd be free to use it
I will try to create something to convert Scratch JSON -> Pseudocode.
- ilovericebubbles
-
100+ posts
How to get Scratch to JavaScript? Support us now!
I'm coming across a problem. I have the variable ‘json’ as the contents of the project.JSON file inside an sb3.outside of Scratch!You would probably have to credit Scratch, but nice Idea! you could then change any parts you want and you'd be free to use it
I will try to create something to convert Scratch JSON -> Pseudocode.
But when I reference a block in the first sprite (the 0th sprite is stage), it comes up with an error.
Here is the reference:
obj.targets[1].blocks.4$mzqKS$7Y`Nr}jjP1f;
the problem is that Scratch identifies blocks as random strings. This contains many reserved characters such as ` , ; and } .
I (for some reason) cannot do \` and \; and \} because it complains about invalid escaping, I cannot do \x64 and such, and I cannot reference it in a string. Good luck figuring it out!
P.S. Yes this is JavaScript in case you forget!
P.P.S Yes I call it ‘JavaScript’ and not ‘Javascript’ or ‘javascript’ or ‘JS’ or ‘js’
P.P.P.S Do you have a problem with that?
P.P.P.P.S Why am I doing this?
Last edited by ilovericebubbles (Nov. 18, 2019 06:47:05)
- Sheep_maker
-
1000+ posts
How to get Scratch to JavaScript? Support us now!
You can do But when I reference a block in the first sprite (the 0th sprite is stage), it comes up with an error.
Here is the reference:obj.targets[1].blocks.4$mzqKS$7Y`Nr}jjP1f;
the problem is that Scratch identifies blocks as random strings. This contains many reserved characters such as ` , ; and } .
obj.targets[1].blocks['4$mzqKS$7Y`Nr}jjP1f'];
- ilovericebubbles
-
100+ posts
How to get Scratch to JavaScript? Support us now!
Thanks!You can do But when I reference a block in the first sprite (the 0th sprite is stage), it comes up with an error.
Here is the reference:obj.targets[1].blocks.4$mzqKS$7Y`Nr}jjP1f;
the problem is that Scratch identifies blocks as random strings. This contains many reserved characters such as ` , ; and } .obj.targets[1].blocks['4$mzqKS$7Y`Nr}jjP1f'];
- Centuriasoft
-
46 posts
How to get Scratch to JavaScript? Support us now!
The nice thing about trying to convert Scratch projects to javascript files is that Scratch projects are stored as JSON files, aka JavaScript Object Notation, the hard part is that scratch's JSON files are a convoluted mess
Also, I'm making my own programming language so there are a few things I've learnt, one is this: You can't just ‘translate’ from one language (Scratch) to another (JS) without considerable effort. You have to break down the scratch program into tokens, create an AST, and then reverse that AST into JS code
Also, I'm making my own programming language so there are a few things I've learnt, one is this: You can't just ‘translate’ from one language (Scratch) to another (JS) without considerable effort. You have to break down the scratch program into tokens, create an AST, and then reverse that AST into JS code
- ilovericebubbles
-
100+ posts
How to get Scratch to JavaScript? Support us now!
You could just parse the JSON into Javascript. The nice thing about trying to convert Scratch projects to javascript files is that Scratch projects are stored as JSON files, aka JavaScript Object Notation, the hard part is that scratch's JSON files are a convoluted mess
Also, I'm making my own programming language so there are a few things I've learnt, one is this: You can't just ‘translate’ from one language (Scratch) to another (JS) without considerable effort. You have to break down the scratch program into tokens, create an AST, and then reverse that AST into JS code
If we could use a Lexicon or YACC in JS, it would probably be reasonably easy.
- Lukesstitch
-
100+ posts
How to get Scratch to JavaScript? Support us now!
This isn't the place for your topic. Instead, go to the Suggestions Forum
- -CodePro-
-
100+ posts
How to get Scratch to JavaScript? Support us now!
PullJosh is making one: https://scratch.mit.edu/projects/345789566/
- ilovericebubbles
-
100+ posts
How to get Scratch to JavaScript? Support us now!
https://scratch.mit.edu/projects/345789566/PullJosh is making one:

- NowDeadly
-
1 post
How to get Scratch to JavaScript? Support us now!
Lukesstitch does it really matter?
- sausagescratch
-
78 posts
How to get Scratch to JavaScript? Support us now!
Nah guys its not pointless because it needs to support cloud variables as well.
- sqlmap
-
23 posts
How to get Scratch to JavaScript? Support us now!
This can be done easily. In fact, I have started making one myself.
All Scratch projects are compiled in JSON. How do you access this JSON? Well, it's very simple. Go to the “See Inside” section of the Scratch project, press File, and hit Download. This will download a sb3 file to your computer - now this file is actually just a zip folder. Change the file extension to zip, and extract it - you should see a json file somewhere among other project assets. Now open that json file in a text editor/viewer, and you will see the project's code in json format! All you need, is a little bit of JavaScript that converts that JSON into working JavaScript code. How? Well, I have recently been using a JavaScript library called “Blocklike” - and you have probably guessed, it's basically Scratch but in JavaScript. You could convert the JSON into Blocklike JavaScript, and you would essentially have a working project outside Scratch. In theory, you could convert it back into a Scratch project, but that could be a little bit harder - and may require Node.js (which is an environment that executes JavaScript code outside of a web browser).
While this is theoretically possible, it would take a considerable amount of time. Supporting cloud variables? Well, you would need a database for that, such as MySQL. I said that I started making a converter myself, well… I had the idea of reading a Scratch sb3 file, and displaying it's block code within a website. A similar idea, however I never got round to making it as i'm busy with other stuff atm.
All Scratch projects are compiled in JSON. How do you access this JSON? Well, it's very simple. Go to the “See Inside” section of the Scratch project, press File, and hit Download. This will download a sb3 file to your computer - now this file is actually just a zip folder. Change the file extension to zip, and extract it - you should see a json file somewhere among other project assets. Now open that json file in a text editor/viewer, and you will see the project's code in json format! All you need, is a little bit of JavaScript that converts that JSON into working JavaScript code. How? Well, I have recently been using a JavaScript library called “Blocklike” - and you have probably guessed, it's basically Scratch but in JavaScript. You could convert the JSON into Blocklike JavaScript, and you would essentially have a working project outside Scratch. In theory, you could convert it back into a Scratch project, but that could be a little bit harder - and may require Node.js (which is an environment that executes JavaScript code outside of a web browser).
While this is theoretically possible, it would take a considerable amount of time. Supporting cloud variables? Well, you would need a database for that, such as MySQL. I said that I started making a converter myself, well… I had the idea of reading a Scratch sb3 file, and displaying it's block code within a website. A similar idea, however I never got round to making it as i'm busy with other stuff atm.
- BlueWonderCam
-
5 posts
How to get Scratch to JavaScript? Support us now!
Actually, there is already a website that converts scratch to JavaScript. It is here: https://forkphorus.github.io/
- trieuminh
-
100+ posts
How to get Scratch to JavaScript? Support us now!
https://forkphorus.github.io/That doesn't really do that… Actually, there is already a website that converts scratch to JavaScript. It is here:
- Sheep_maker
-
1000+ posts
How to get Scratch to JavaScript? Support us now!
It does, but it doesn't show the converted code because it's not made for manual editing, unlike Leopard.https://forkphorus.github.io/That doesn't really do that… Actually, there is already a website that converts scratch to JavaScript. It is here:
- trieuminh
-
100+ posts
How to get Scratch to JavaScript? Support us now!
I know it does. That's why I said that it doesn't really do that.It does, but it doesn't show the converted code because it's not made for manual editing, unlike Leopard.https://forkphorus.github.io/That doesn't really do that… Actually, there is already a website that converts scratch to JavaScript. It is here:
- block200
-
100+ posts
How to get Scratch to JavaScript? Support us now!
It might not to you but others might find it interesting. Lukesstitch does it really matter?
- ilovericebubbles
-
100+ posts
How to get Scratch to JavaScript? Support us now!
I've had a look at Leopard, I'm not sure if that is what this question was about because it imports a library and then is written like a text-based Scratch.It does, but it doesn't show the converted code because it's not made for manual editing, unlike Leopard.https://forkphorus.github.io/That doesn't really do that… Actually, there is already a website that converts scratch to JavaScript. It is here:
I think that if you are going to translate Scratch to JavaScript, you want it without any libraries or behind-the-scenes, or ‘vanilla’ if you will.
If you want it like Leopard does, you may as well just have a typed version of Scratch.
- Discussion Forums
- » Open Source Projects
-
» How to get Scratch to JavaScript? Support us now!