Discuss Scratch

superben100
Scratcher
1000+ posts

Making a Comment Block Extension

NOTE: You or anyone else may not share your extension in any online Scratch projects. It is prohibited. For more information on sharing your extension, see here.
Hello everyone! Today, I am going to display to you how to create a very basic, first Scratch extension. To start, make sure that you have a web browser like Chrome, or any browser that includes a built-in JavaScript editor. Now, open another tab, and goto the Scratch website, and click “Create” in the top-left corner. Now, open up the JavaScript console and flip back to this tab. Now copy this code:
(function(ext) {
// Cleanup function when the extension is unloaded
ext._shutdown = function() {};

// Status reporting code
// Use this to report missing hardware, plugin or unsupported browser
ext._getStatus = function() {
return {status: 2, msg: ‘Ready’};
};

ext.my_first_block = function() {
// Code that gets executed when the block is run
};

// Block and block menu descriptions
var descriptor = {
blocks: [
// Block type, block name, function name
[' ‘, ’1', '2'],
]
};

// Register the extension
ScratchExtensions.register('3', descriptor, ext);
})({});
Now, go to the editor tab. Next, paste it in, and now comes the fun part. Replace the 1 with “comment %s”, the 2 with “comment_%s” and the 3 with “Comment”. (Make sure to keep the ‘s, but don’t add in the “s.) Press enter, and, if done correctly, it should say ”undefined“, and it should appear in the ”More Blocks" menu. If it gives you a syntax error, you retry a few times, and if it still doesn't work, comment your code and error below, and I will try, to the best of my ability, to fix it. Remember: Do not share your extension in an online project. For more information on sharing your extension, click here.

Last edited by superben100 (Feb. 19, 2016 23:58:58)

liam48D
Scratcher
1000+ posts

Making a Comment Block Extension

Looks cool!

I noticed a couple typos, though: "now, goto the editor tab“ and ”sharing you're extension".
superben100
Scratcher
1000+ posts

Making a Comment Block Extension

liam48D wrote:

Looks cool!

I noticed a couple typos, though: "now, goto the editor tab“ and ”sharing you're extension".
Thanks!
superben100
Scratcher
1000+ posts

Making a Comment Block Extension

Note: I'm gonna close this topic because for some odd reason, nothing wants to work. Check out a better tutorial here. Sorry about this. This tutorial fails to work. Sorry

Last edited by superben100 (Feb. 20, 2016 00:08:23)

Powered by DjangoBB