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
100 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.

I have about 1700 posts, 60 projects, and 65 followers.

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
Scratch 3.0 blocks but less fat
.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.

I have about 1700 posts, 60 projects, and 65 followers.

dalelane
Scratcher
3 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 :-)
OnMax
Scratcher
14 posts

Creating extensions for Scratch 3.0

Hello there.
Thanks for creating this topic, it was really helpful!
I'm now working on the “Firebase Database Extension”. It is a Google's realtime Database. I need first ask for Google's permission and then I'll start working. Here are some blocks for extensions:
add value key [name] value [Alex]::pen

(get value key [name]::pen)

get all keys to list [my list v] ::pen

push value from list [my list v] ::pen

Thanks again

when I start as a clone
forever
if <not <<key [space v] pressed>=(1)>> then
say (round ([sin v] of (☁ data))) for (((☁ data) * (33.33)) mod (0)) secs
end
change [☁ data v] by <key [space v] pressed?>
end

Who understand this?
OnMax
Scratcher
14 posts

Creating extensions for Scratch 3.0

Please, help!

I need help with this extension ! I wrote simple alert display extension and I used Sheep_maker's scratch guitar with load URL. What wrong with it? Please help!!!

when I start as a clone
forever
if <not <<key [space v] pressed>=(1)>> then
say (round ([sin v] of (☁ data))) for (((☁ data) * (33.33)) mod (0)) secs
end
change [☁ data v] by <key [space v] pressed?>
end

Who understand this?
Sheep_maker
Scratcher
1000+ posts

Creating extensions for Scratch 3.0

OnMax wrote:

Please, help!

I need help with this extension ! I wrote simple alert display extension and I used Sheep_maker's scratch guitar with load URL. What wrong with it? Please help!!!
It's Scratch.BlockType.STRING, not Scratch.blockType.STRING

- Sheep_maker This is a kumquat-free signature. :P
Scratch 3.0 blocks but less fat
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
OnMax
Scratcher
14 posts

Creating extensions for Scratch 3.0

Sheep_maker wrote:

OnMax wrote:

Please, help!

I need help with this extension ! I wrote simple alert display extension and I used Sheep_maker's scratch guitar with load URL. What wrong with it? Please help!!!
It's Scratch.BlockType.STRING, not Scratch.blockType.STRING
Thanks a lot! I often make mistakes in JavaScript with register

when I start as a clone
forever
if <not <<key [space v] pressed>=(1)>> then
say (round ([sin v] of (☁ data))) for (((☁ data) * (33.33)) mod (0)) secs
end
change [☁ data v] by <key [space v] pressed?>
end

Who understand this?
OnMax
Scratcher
14 posts

Creating extensions for Scratch 3.0

Sheep_maker wrote:

OnMax wrote:

Please, help!

I need help with this extension ! I wrote simple alert display extension and I used Sheep_maker's scratch guitar with load URL. What wrong with it? Please help!!!
It's Scratch.BlockType.STRING, not Scratch.blockType.STRING
I now know where's the error. There must be not blockType. There must be ArgumentType. Thanks everyone

when I start as a clone
forever
if <not <<key [space v] pressed>=(1)>> then
say (round ([sin v] of (☁ data))) for (((☁ data) * (33.33)) mod (0)) secs
end
change [☁ data v] by <key [space v] pressed?>
end

Who understand this?
OnMax
Scratcher
14 posts

Creating extensions for Scratch 3.0

Hi, guys.

I started working with TextToSpeech extension that uses that code:

window.speechSynthesis.speak();

Last edited by OnMax (Aug. 1, 2018 14:21:41)


when I start as a clone
forever
if <not <<key [space v] pressed>=(1)>> then
say (round ([sin v] of (☁ data))) for (((☁ data) * (33.33)) mod (0)) secs
end
change [☁ data v] by <key [space v] pressed?>
end

Who understand this?
OnMax
Scratcher
14 posts

Creating extensions for Scratch 3.0

NOW I REALLY NEED HELP!

Guys, please tell me, what's wrong with this extension?

Actually, it works fine and all the reporters and basic functions are working. But I wrote…

44 speechsay({TEXT}) {
45 sayedtxt = TEXT;
46 var msg = new SpeechSynthesisUtterance(TEXT);
47 window.speechSynthesis.speak(msg);
48 }


…and the speech command (47) doesn't works!

Please tell me, what's wrong with this, because everything works fine, exept of the speech.

P.S: Also, the speech script works in the simple HTML page, but not in the Scratch 3.0 GUI with url button.

Last edited by OnMax (Aug. 1, 2018 14:22:34)


when I start as a clone
forever
if <not <<key [space v] pressed>=(1)>> then
say (round ([sin v] of (☁ data))) for (((☁ data) * (33.33)) mod (0)) secs
end
change [☁ data v] by <key [space v] pressed?>
end

Who understand this?
Sheep_maker
Scratcher
1000+ posts

Creating extensions for Scratch 3.0

OnMax wrote:

Hi, guys.

I started working with TextToSpeech extension that uses that code:

window.speechSynthesis.speak();

Extensions are run in their own worker; window does not exist in workers, they use self.

- Sheep_maker This is a kumquat-free signature. :P
Scratch 3.0 blocks but less fat
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
OnMax
Scratcher
14 posts

Creating extensions for Scratch 3.0

Sheep_maker wrote:

OnMax wrote:

Hi, guys.

I started working with TextToSpeech extension that uses that code:

window.speechSynthesis.speak();

Extensions are run in their own worker; window does not exist in workers, they use self.
Do you mean, I can just use self instead of window?

when I start as a clone
forever
if <not <<key [space v] pressed>=(1)>> then
say (round ([sin v] of (☁ data))) for (((☁ data) * (33.33)) mod (0)) secs
end
change [☁ data v] by <key [space v] pressed?>
end

Who understand this?
PullJosh
Scratcher
1000+ posts

Creating extensions for Scratch 3.0

OnMax wrote:

Sheep_maker wrote:

OnMax wrote:

Hi, guys.

I started working with TextToSpeech extension that uses that code:

window.speechSynthesis.speak();

Extensions are run in their own worker; window does not exist in workers, they use self.
Do you mean, I can just use self instead of window?
Haven't tested myself, but it looks like yes.

OnMax
Scratcher
14 posts

Creating extensions for Scratch 3.0

PullJosh wrote:

OnMax wrote:

Sheep_maker wrote:

OnMax wrote:

Hi, guys.

I started working with TextToSpeech extension that uses that code:

window.speechSynthesis.speak();

Extensions are run in their own worker; window does not exist in workers, they use self.
Do you mean, I can just use self instead of window?
Haven't tested myself, but it looks like yes.
Thanks, PullJosh. I'll try it

when I start as a clone
forever
if <not <<key [space v] pressed>=(1)>> then
say (round ([sin v] of (☁ data))) for (((☁ data) * (33.33)) mod (0)) secs
end
change [☁ data v] by <key [space v] pressed?>
end

Who understand this?

Powered by DjangoBB

Standard | Mobile