Discuss Scratch

JGames101
Scratcher
100+ posts

Creating extensions for Scratch 3.0

Oh wow, extensions have changed a lot.
I guess that's why they recommend to not use pre-release software too much…

I was trying to create another basic extension in Scratch 3, just using the speech synthesis api to say whatever you enter, but I ran into a lot of problems.
First problem: After copying the example extension, and writing my extension, I went over to set the extensionURL for my extension, but discovered something that shocked me to my core…
extensionURL has become extensionId!!!!!
So I replaced the pen extension with my new one to make my life easier. Then, I realized…
The extension format has completely changed.
Well, quite a bit, anyway.

So… the basic way that it now works is that we have a class. This class has a constructor to setup the extension, a “getInfo” function to return whatever information for the extension (similar to how it was defined before), and then any functions for the blocks. You need to use require() to import some things for it to work. It doesn't sound that big, and it shouldn't be too hard to port from the older format, but still, It's pretty different.

Here's the new format (with the new google translate extension).

I'm getting weird errors right now, to do with event dispatches needing to be strings in a completely different file… but I'll update if I get any breakthroughs.

Last edited by JGames101 (June 17, 2018 04:12:12)



Hey! I like working with Scratch 3.

Scratch 3 Modding

My Website
NitroCipher
Scratcher
100+ posts

Creating extensions for Scratch 3.0

JGames101 wrote:

Oh wow, extensions have changed a lot.
I guess that's why they recommend to not use pre-release software too much…

I was trying to create another basic extension in Scratch 3, just using the speech synthesis api to say whatever you enter, but I ran into a lot of problems.
First problem: After copying the example extension, and writing my extension, I went over to set the extensionURL for my extension, but discovered something that shocked me to my core…
extensionURL has become extensionId!!!!!
So I replaced the pen extension with my new one to make my life easier. Then, I realized…
The extension format has completely changed.
Well, quite a bit, anyway.

So… the basic way that it now works is that we have a class. This class has a constructor to setup the extension, a “getInfo” function to return whatever information for the extension (similar to how it was defined before), and then any functions for the blocks. You need to use require() to import some things for it to work. It doesn't sound that big, and it shouldn't be too hard to port from the older format, but still, It's pretty different.

Here's the new format (with the new google translate extension).

I'm getting weird errors right now, to do with event dispatches needing to be strings in a completely different file… but I'll update if I get any breakthroughs.

Welp, it looks like i'm going to have some more fun trying to write a converter than I thought I will probably hold off until the ST finally finalizes their formatting. Thanks for the update!

I hope my post helped you in some way! Post count: 400+

Current project: [s3Blocks: scratchblocks rewritten for Scratch 3.0] ::extension //https://scratch.mit.edu/discuss/topic/290031/
This is my signature identifier “aWFtbml0cm9jaXBoZXI=”
zachary123212
Scratcher
1 post

Creating extensions for Scratch 3.0

Well, after an exhausting amount of backtracking, I've managed to get the new version of scratch to add a local extension, but still can't figure out how to get it to work with URLs. What I've done is this (say you want to add an extension named X):
  1. fork, clone, and link the scratch-vm and scratch-gui repos
  2. in scratch-vm/src/extensions add a directory called X, containing your extension's index.js file, and any relevant assets
  3. in scratch-vm/src/extension-support/extension-manager.js, near the top of the file, add the line:
    const Scratch3XBlocks = require('../extensions/X');
  4. a bit further down, at the end of const builtinExtensions, add the line (with the requisite comma preceding it):
    X: Scratch3XBlocks
  5. go to scratch-gui/src/lib/libraries/extensions/index.jsx and add an entry with X as extensionId

Does anyone know how to pass in a remote URL directly in index.jsx, so I don't need to repeat steps 1-4?
A48c
Scratcher
71 posts

Creating extensions for Scratch 3.0

discoverypark wrote:

How about if you could make your own extensions? (in scratch 3.0)
You can.
LuckyLucky7
Scratcher
1000+ posts

Creating extensions for Scratch 3.0

kyleplo wrote:

Try this: https://github.com/kyleplo/scratch-three-extension-docs/wiki/Getting-Started
Seems pretty neat. Maybe I can experiment with this and probably add this to my mod.

Check out my Lucky7(Scratch 3) Mod down below!

Sheep_maker
Scratcher
1000+ posts

Creating extensions for Scratch 3.0

I've modified scratch-gui and added a button in the extensions library that loads extensions from a URL.

Most of the functionality seems to have already been put in place; they just haven't added a button for it yet.

Because of how extensions are registered, external extensions don't have access to the magical “runtime” thing which means you can't do much with the default Scratch unlike the currently provided extensions. Maybe I'll find a way to change that.

I made an extension with a few reporter blocks here.

Edit: updated URL because the builder was being disobedient.

Last edited by Sheep_maker (July 10, 2018 11:58:28)


- Sheep_maker This is a kumquat-free signature. :P
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
LuckyLucky7
Scratcher
1000+ posts

Creating extensions for Scratch 3.0

Sheep_maker wrote:

I've modified scratch-gui and added a button in the extensions library that loads extensions from a URL.

Most of the functionality seems to have already been put in place; they just haven't added a button for it yet.

Because of how extensions are registered, external extensions don't have access to the magical “runtime” thing which means you can't do much with the default Scratch unlike the currently provided extensions. Maybe I'll find a way to change that.

I made an extension with a few reporter blocks here.
Looks like I'll use this extension to test out the blocks for my Lucky7 Mod.

Check out my Lucky7(Scratch 3) Mod down below!

dalelane
Scratcher
2 posts

Creating extensions for Scratch 3.0

Sheep_maker wrote:

I've modified scratch-gui and added a button in the extensions library that loads extensions from a URL.

Thanks so much for sharing this. This (and this issue in particular) looks like it'll be exactly what I need to try and port my Scratchx work over to Scratch 3. Looking forward to giving it a try :-)

Powered by DjangoBB

Standard | Mobile