Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Leopard: Edit Scratch projects as JavaScript code
- jvn11
-
Scratcher
70 posts
Leopard: Edit Scratch projects as JavaScript code
Hey @PullJosh. I made this program that first asks you for your username, then it outputs your username + date & time.
https://codesandbox.io/s/ecstatic-faraday-ewlvco
https://codesandbox.io/s/ecstatic-faraday-ewlvco

- PullJosh
-
Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
Leopard updates!
Thanks to towerofnix and adroitwhiz, Leopard has some new updates to share!
Leopard now supports the following blocks:
Additionally, pen and “when this sprite clicked” were both made more compatible with Scratch. And now that “touching edge” is available, support for “if on edge, bounce” is closer than ever.
Thanks to towerofnix and adroitwhiz, Leopard has some new updates to share!
Leopard now supports the following blocks:
when [timer v] > (10)
when [loudness v] > (10)
(loudness)
<touching [edge v] ?>
Additionally, pen and “when this sprite clicked” were both made more compatible with Scratch. And now that “touching edge” is available, support for “if on edge, bounce” is closer than ever.
- PullJosh
-
Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
The Leopard website now features a live-updating list of recently converted projects. Hopefully now it's easier to find and connect with other Scratchers who are using Leopard. Give it a try! 

- NoodlesAdun
-
Scratcher
2 posts
Leopard: Edit Scratch projects as JavaScript code
Hello, I was trying to convert a project using leopard but it keeps giving the error message “Cannot read properties of undefined (reading ‘0’)”.
I'm not using any unsupported blocks or extensions, so does anyone know where I've gone wrong?
the project url is: https://scratch.mit.edu/projects/714577157
I'm not using any unsupported blocks or extensions, so does anyone know where I've gone wrong?
the project url is: https://scratch.mit.edu/projects/714577157
- Taro--Sasaki
-
Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
Does it work on mob.?
- Aneri9714
-
Scratcher
100+ posts
Leopard: Edit Scratch projects as JavaScript code
It's amazing! I can now learn js (little bit?)
- -Cold-lord-X-
-
Scratcher
100+ posts
Leopard: Edit Scratch projects as JavaScript code
finally. Trying it out now!
Last edited by -Cold-lord-X- (Aug. 2, 2022 16:27:09)
- PullJosh_Test
-
Scratcher
7 posts
Leopard: Edit Scratch projects as JavaScript code
Hello, I was trying to convert a project using leopard but it keeps giving the error message “Cannot read properties of undefined (reading ‘0’)”.Great question! I did some digging and found that there are two separate issues that both cause this error.
I'm not using any unsupported blocks or extensions, so does anyone know where I've gone wrong?
the project url is: https://scratch.mit.edu/projects/714577157
Problem 1: The first is that you have a variable and a list with matching names. This is something Leopard should know how to handle, but it currently doesn't. That's our fault, and it should work, but in the meantime you can always rename your lists to make them not match the variables, and that will solve this issue.
Problem 2: The second problem is a little weirder. It seems like in the “editor” sprite, the variables tileGridX, tileGridY, tileIndex, and tile are each defined twice. This isn't visible at all in the Scratch editor, but you can see it when you open up the JSON code under the hood. I have no idea how this happened–I don't think it's supposed to be possible.
Here's an excerpt from your project's underlying JSON code so that you can see what I mean:
{ "isStage": false, "name": "editor", "variables": { "W_1Y0o*^b}}4=Y+cjm2g": ["tileGridX", 8], "Vjh+7?#YS@#6q-B-/@%T": ["tileGridY", 8], "rYY+5aWXjq/pBK8^Gt}w": ["tileIndex", 169], "}h`kH)KZh-HrN9g!t-Ny": ["tile", "2"], "0?:.QV{uMFG;@i]L!h1n": ["brush", "0"], "7De62Pt(pTCegwvxFOvY": ["brush1", 1], "dx(wx8v7)/y!iWIhW1CH": ["brush2", 1], "]LIbaT9ymB}x1antS-|d": ["brush3", 10], "NkJRP6FQdQ3YU#Aei/=r": ["tileGridX", 0], "(_.u_-_ZB09^R`v2~*.K": ["tileGridY", 0], "aGQ*p%}CAQLiF45ZB6n~": ["tileIndex", 0], "1{y0BG5T,ZjEF4{Kgl#t": ["tile", 0], "@pi?X+CgpM=SZ[B4~`}q": ["brush4", 3], "^VrYP)X.I;MP}r6D2FYe": ["brush5", 0], "_qt3@[rs*m=(`ZfC-T#|": ["brush6", 9], "OU,k{M/7-Q4|=+kuC3SY": ["brush#", "2"], "t1cz`Jspd|;lIPxKu(vK": ["brush7", 0] }, // etc... }
Under the hood, variables are given ids that are basically just strings of garbage (in green above). What's weird is that there are two variables called tileGridX, two variables called tileGridY, and so on. (But there is just one of each “brush” variable as expected.) This obviously makes Leopard very confused, and causes the error. Fixing this one seems harder because I don't know how it even happened in the first place.
- NoodlesAdun
-
Scratcher
2 posts
Leopard: Edit Scratch projects as JavaScript code
Hello, I was trying to convert a project using leopard but it keeps giving the error message “Cannot read properties of undefined (reading ‘0’)”.Great question! I did some digging and found that there are two separate issues that both cause this error.
I'm not using any unsupported blocks or extensions, so does anyone know where I've gone wrong?
the project url is: https://scratch.mit.edu/projects/714577157
Problem 1: The first is that you have a variable and a list with matching names. This is something Leopard should know how to handle, but it currently doesn't. That's our fault, and it should work, but in the meantime you can always rename your lists to make them not match the variables, and that will solve this issue.
Problem 2: The second problem is a little weirder. It seems like in the “editor” sprite, the variables tileGridX, tileGridY, tileIndex, and tile are each defined twice. This isn't visible at all in the Scratch editor, but you can see it when you open up the JSON code under the hood. I have no idea how this happened–I don't think it's supposed to be possible.
Here's an excerpt from your project's underlying JSON code so that you can see what I mean:{ "isStage": false, "name": "editor", "variables": { "W_1Y0o*^b}}4=Y+cjm2g": ["tileGridX", 8], "Vjh+7?#YS@#6q-B-/@%T": ["tileGridY", 8], "rYY+5aWXjq/pBK8^Gt}w": ["tileIndex", 169], "}h`kH)KZh-HrN9g!t-Ny": ["tile", "2"], "0?:.QV{uMFG;@i]L!h1n": ["brush", "0"], "7De62Pt(pTCegwvxFOvY": ["brush1", 1], "dx(wx8v7)/y!iWIhW1CH": ["brush2", 1], "]LIbaT9ymB}x1antS-|d": ["brush3", 10], "NkJRP6FQdQ3YU#Aei/=r": ["tileGridX", 0], "(_.u_-_ZB09^R`v2~*.K": ["tileGridY", 0], "aGQ*p%}CAQLiF45ZB6n~": ["tileIndex", 0], "1{y0BG5T,ZjEF4{Kgl#t": ["tile", 0], "@pi?X+CgpM=SZ[B4~`}q": ["brush4", 3], "^VrYP)X.I;MP}r6D2FYe": ["brush5", 0], "_qt3@[rs*m=(`ZfC-T#|": ["brush6", 9], "OU,k{M/7-Q4|=+kuC3SY": ["brush#", "2"], "t1cz`Jspd|;lIPxKu(vK": ["brush7", 0] }, // etc... }
Under the hood, variables are given ids that are basically just strings of garbage (in green above). What's weird is that there are two variables called tileGridX, two variables called tileGridY, and so on. (But there is just one of each “brush” variable as expected.) This obviously makes Leopard very confused, and causes the error. Fixing this one seems harder because I don't know how it even happened in the first place.
It's possible that when I was editing the project with turbowarp it somehow duplicated the variables, I'll try remaking the sprite and renaming the lists and hopefully it will work then. Thanks for the help!
- cdawgscratch
-
Scratcher
1 post
Leopard: Edit Scratch projects as JavaScript code
leapord is so cool but its very laggy on my device for some reason, do you think there might be something causing that?
- PullJosh
-
Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
It's possible that when I was editing the project with turbowarp it somehow duplicated the variables, I'll try remaking the sprite and renaming the lists and hopefully it will work then. Thanks for the help!
Let me know how it goes!

- PullJosh
-
Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
leapord is so cool but its very laggy on my device for some reason, do you think there might be something causing that?I'm not sure. What kind of device are you on? And is it always laggy or only for certain projects?
- A-MARIO-PLAYER
-
Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
I'm not sure why nobody has posted this. My project keeps failing with:
Argument sandboxId for data.sandboxId is missing.
Last edited by A-MARIO-PLAYER (Aug. 6, 2022 14:45:13)
- PullJosh
-
Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
I'm not sure why nobody has posted this. My project keeps failing with:Which project is failing?Argument sandboxId for data.sandboxId is missing.
- BloodstoneAsh
-
Scratcher
7 posts
Leopard: Edit Scratch projects as JavaScript code
Following along with what a mario player said, I also have the same question. I had remixed griffpatch's Paper Minecraft project just for kicks to look at the code and stuff, but I am also wondering why I get an argument sandboxId for data.sandboxId is missing.
Last edited by BloodstoneAsh (Aug. 10, 2022 21:05:08)
- Time-lapse-studios
-
Scratcher
1 post
Leopard: Edit Scratch projects as JavaScript code
Hey I uploaded this project: https://scratch.mit.edu/projects/686612887/
but when I converted it to JavaScript a button that was supposed to do something didn't work even though it did on scratch. Can you help?
Here's the javascript version: https://croq5s.csb.app/
but when I converted it to JavaScript a button that was supposed to do something didn't work even though it did on scratch. Can you help?
Here's the javascript version: https://croq5s.csb.app/
Last edited by Time-lapse-studios (Aug. 11, 2022 05:08:56)
- cyAn_5648
-
Scratcher
3 posts
Leopard: Edit Scratch projects as JavaScript code
hi, I have this project, but it also gives an Argument sandboxId for data.sandboxId is missing. error.
send help pls, what's going wrong?
here's the project link if you're curious: https://scratch.mit.edu/projects/722167498/
send help pls, what's going wrong?
here's the project link if you're curious: https://scratch.mit.edu/projects/722167498/

Last edited by cyAn_5648 (Aug. 16, 2022 05:40:32)
- Do_not_create
-
Scratcher
9 posts
Leopard: Edit Scratch projects as JavaScript code
I put in https://scratch.mit.edu/projects/721027674/
and result was
and result was
Cannot read properties of undefined (reading ‘0’)
Last edited by Do_not_create (Aug. 16, 2022 06:59:26)
- WesleyMcGinn
-
Scratcher
1 post
Leopard: Edit Scratch projects as JavaScript code
This leopard converter is really cool! I am trying to learn more JavaScript with the manual translations page but I noticed that there was no translation available for a cloud variable. (Link) I also noticed that fixing this issue is not on the upcoming improvements list. What alternative methods are there for simple data transfer across the cloud in JavaScript? (Suppose I have a variable called “variable” and I want it to be set equal to 12 on all devices on a website. How would I do that?)
- ego-lay_atman-bay
-
Scratcher
500+ posts
Leopard: Edit Scratch projects as JavaScript code
(#586)That's actually a lot more complicated than you think. You need a server in order to use cloud variables. I'd suggest that you don't worry about it.
This leopard converter is really cool! I am trying to learn more JavaScript with the manual translations page but I noticed that there was no translation available for a cloud variable. (Link) I also noticed that fixing this issue is not on the upcoming improvements list. What alternative methods are there for simple data transfer across the cloud in JavaScript? (Suppose I have a variable called “variable” and I want it to be set equal to 12 on all devices on a website. How would I do that?)