Discuss Scratch

snoopydaniels
Scratcher
7 posts

The Future of Scratch Extensions

I've been reading through this forum trying to find information about what the plans are for Scratch extensions. As far as I can tell, the current state of affairs is that unofficial Scratch 3.0 extensions are not supported except if you want to create your own custom build. And if unofficial extensions are ever supported, they will not be able to interact with the stage or the project.

The inability to create custom extensions that interact with the stage and other sprites and use them outside of ScratchX is a major drawback, a much greater drawback than I think the developers of Scratch realize, and I'm not sure why it's an afterthought. The ability to implement your own blocks using text code, blocks that can do anything that other existing blocks can do, would provide a perfect transition for young programmers between block coding and text coding. As things stand, a dedicated student will pretty quickly outgrow Scratch and be forced to move on to some other platform, where much of the things they learned about Scratch will not apply.

Given that Scratch is now based on HTML and JavaScript, would it be terribly difficult to support 3rd (or at least 1st) party extensions that have access to the lower level API that no doubt exists underneath the blocks? Why aren't unofficial extensions already supported, and why don't extensions have access to all of the same objects and blocks that the built-in block do?

Sorry if this just sounds like someone complaining. I'm an experienced web developer who is willing to actually help out with the project rather than just point out its shortcomings.
Sheep_maker
Scratcher
1000+ posts

The Future of Scratch Extensions

Unofficial extensions are run in web workers so they can't access the DOM (so an extension can't click the love button of the project automatically, for example). However, that means that the extensions can't directly access the VM like built-in extensions, which aren't run in a worker.

Perhaps the dispatch used by extension-worker.js could be made global within the worker, but this probably isn't the best solution, nor would it give unofficial workers full functionality.

- Sheep_maker This is a kumquat-free signature. :P
This is my signature. It appears below all my posts. Discuss it on my profile, not the forums. Here's how to make your own.
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
snoopydaniels
Scratcher
7 posts

The Future of Scratch Extensions

Are you saying that extensions are run in web workers for the express purpose of preventing them from accessing the DOM, or that this is just an added benefit of running them in web workers? Would it be possible to post a message to each unofficial extension containing a subset of APIs that give them access to the various Scratch objects in a project?

I haven't looked at the source yet, so this is more pseudocode than code, but here's an example:

let extensionScope = new Scratch.ExtensionScope();

extensionWorker.postMessage(extensionScope);

Then, in the extension:

var scope;

onmessage = function(extensionScope) {
scope = extensionScope;
start();
};

ExtensionScope would provide the API that an extension is allowed to interact with.

var moveBlock = new Scratch.movement.MoveStepsBlock(10);
var mySprite = scope.GetSprite('my sprite');

moveBlock.apply(mySprite);

Last edited by snoopydaniels (June 14, 2019 13:57:39)

mariofutire
New to Scratch
4 posts

The Future of Scratch Extensions

At the bottom of this message

https://scratch.mit.edu/discuss/topic/277217/?page=1#post-2832219

there is an example of loading a custom extension in what seems a normal Scratch 3

https://sheeptester.github.io/scratch-gui/?url=https://nitrocipher.github.io/ext2to3/ext-test.js

how does this work?
Is this plain scratch? Does not seem to be.

If I try this on my local scratch server

http://localhost:8601/?url=https://nitrocipher.github.io/ext2to3/ext-test.js

it does not load it.
SimpleScratch
Scratcher
500+ posts

The Future of Scratch Extensions

there is an example of loading a custom extension in what seems a normal Scratch 3
It is not a normal Scratch 3 - its a modified version
That's why you can't load those type of extensions on your own local Scratch 3 build

Powered by DjangoBB