Discuss Scratch

wesley_griff
Scratcher
6 posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

octoboycrazy wrote:

I tried to use it but don't works
see there i'm not lying it's really not working anymore
@ego-lay_atman-bay
wesley_griff
Scratcher
6 posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

it really doesn't work, a few months ago it worked but I think they turned off the server
jvn11
Scratcher
70 posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

hey. I was thinking if I can help with leopard? I know JavaScript, Python, html, css, and scratch (obv).

I’m @jvn11

CONSIDER FOLLOWING ME ON SCRATCH AND YOUTUBE!

forever
Be [awesome] and [kind]
Always.
Yes
end

—————————————————————
PullJosh
Scratcher
1000+ posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

jvn11 wrote:

hey. I was thinking if I can help with leopard? I know JavaScript, Python, html, css, and scratch (obv).
Right now I really want help discovering cool ideas for how to use Leopard. Converting Scratch projects to JavaScript is obviously cool, but the most exciting part is if you can start to add JavaScript code to your project that enables new features that aren't possible in Scratch.

For example, using Leopard you could enhance your project by:
  • Making a sprite that opens a website in a new tab when clicked
  • Using JavaScript alert(), prompt(), and confirm() boxes
  • Changing other things on the webpage, like the page's background color, or adding new HTML elements

These are my ideas, but I feel like there is a lot more to do that I just haven't thought of yet. It would be fun to build a library of cool project ideas, and I need help doing so. Maybe you could contribute some ideas and example projects?
PullJosh
Scratcher
1000+ posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

Here's an example of what I'm talking about, jvn11: https://codesandbox.io/s/stoic-golick-i6st4h?file=/Sprite1/Sprite1.js

When you click the Scratch cat, it opens the Scratch website in a new tab. Not possible in a regular Scratch project!

Everyone reading this, please create more example projects like this one! I want to see all your ideas.
jvn11
Scratcher
70 posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

PullJosh wrote:

Here's an example of what I'm talking about, jvn11: https://codesandbox.io/s/stoic-golick-i6st4h?file=/Sprite1/Sprite1.js

When you click the Scratch cat, it opens the Scratch website in a new tab. Not possible in a regular Scratch project!

Everyone reading this, please create more example projects like this one! I want to see all your ideas.

so something like a scratch extension? the problem is that I don’t know how to actually make one
but what I can do is to probably make this into an npm module (if you haven’t already published one yet)

I’m @jvn11

CONSIDER FOLLOWING ME ON SCRATCH AND YOUTUBE!

forever
Be [awesome] and [kind]
Always.
Yes
end

—————————————————————
PullJosh
Scratcher
1000+ posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

jvn11 wrote:

so something like a scratch extension? the problem is that I don’t know how to actually make one
but what I can do is to probably make this into an npm module (if you haven’t already published one yet)

No need to write an extension. After converting your project to Leopard code, you can edit the JavaScript to do whatever you want! Even things that are impossible in Scratch.

For example, to create the project I linked above, I started by creating a Scratch project that did nothing when you clicked on the Scratch cat. Then I converted my project to Leopard. The converted project still did nothing when clicking the cat. But now, because I was working in JavaScript land, I could add that additional functionality myself, without relying on the automatic converter.

Try editing my JavaScript code in the example project. Can you change it to open a different website?
jvn11
Scratcher
70 posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

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

I’m @jvn11

CONSIDER FOLLOWING ME ON SCRATCH AND YOUTUBE!

forever
Be [awesome] and [kind]
Always.
Yes
end

—————————————————————
PullJosh
Scratcher
1000+ posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

Leopard updates!

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: Convert Scratch projects to JavaScript AUTOMATICALLY!

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: Convert Scratch projects to JavaScript AUTOMATICALLY!

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
Taro--Sasaki
Scratcher
1000+ posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

Does it work on mob.?

rec room on top
gimme gifts
Aneri9714
Scratcher
100+ posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

It's amazing! I can now learn js (little bit?)

Abandoned forumer

-Cold-lord-X-
Scratcher
100+ posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

finally. Trying it out now!

Last edited by -Cold-lord-X- (Aug. 2, 2022 16:27:09)


This is my signature, it appears on all my posts.
I just can't refrain
Bitterness, so quaint
One more shot, never again
All the excuses, always the same
All the times I tried
I just couldn't get over you
I just cannot hide
The satisfaction you can brew
One more sip embraced
My worries disappear for a while
Then it all comes, comes kicking in

They told me it's alright
They say that I'll get through
But however hard that I try
I just can get over you
When it all comes kicking in, again

Now I'm shaken
Stirred, awaken
It's taken this pain
To realize the truth
You have been through
All the things I've been through
You can be my muse
I'll write these songs for you
PullJosh_Test
Scratcher
7 posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

NoodlesAdun wrote:

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
Great question! I did some digging and found that there are two separate issues that both cause this error.

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: Convert Scratch projects to JavaScript AUTOMATICALLY!

PullJosh_Test wrote:

NoodlesAdun wrote:

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
Great question! I did some digging and found that there are two separate issues that both cause this error.

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: Convert Scratch projects to JavaScript AUTOMATICALLY!

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: Convert Scratch projects to JavaScript AUTOMATICALLY!

NoodlesAdun wrote:

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: Convert Scratch projects to JavaScript AUTOMATICALLY!

cdawgscratch wrote:

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
42 posts

Leopard: Convert Scratch projects to JavaScript AUTOMATICALLY!

I'm not sure why nobody has posted this. My project keeps failing with:

Leopard translator error wrote:

Argument sandboxId for data.sandboxId is missing.

Last edited by A-MARIO-PLAYER (Aug. 6, 2022 14:45:13)



My signature is protected using KumquatSpray to eat kumquats before they eat my signature.

Flash 32.0 (release 0)
(If you wonder why i still use flash, its cause i have ruffle emulator installed.)

Powered by DjangoBB