Discuss Scratch

JGames101
Scratcher
100+ posts

My first Scratch Extension

I've been playing around with Scratch Extensions recently, and here's my first extension:
Basically, it's not very useful, but it was fun to make anyway.
<true :: extension>
<false :: extension>

So, because I'm a beginner at extensions, the only way to load it is to paste in the code into the console:
(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.false_block = function() {
        return false;
    };
	
    ext.true_block = function() {
        return true;
    };
    // Block and block menu descriptions
    var descriptor = {
        blocks: [
            // Block type, block name, function name, param1 default value, param2 default value
            ['b', 'false', 'false_block'],
			['b', 'true', 'true_block'],
        ]
    };
    // Register the extension
    ScratchExtensions.register('Boolean Blocks by @JGames101', descriptor, ext);
})({});
And, yeah, it has comments that I used to develop it, because I've never written an extension before.
But anyway, thanks for reading, and please give me feedback on my extension that I made!

@JGames101
@JGames101-Tutorials

Last edited by JGames101 (Nov. 10, 2016 22:28:15)

Jonathan50
Scratcher
1000+ posts

My first Scratch Extension

Good job! But the Scratch forums have messed up your code. Instead of using quote tags, you can use code tags (and these display the code in a monospace font so it's easier to read).

Not yet a Knight of the Mu Calculus.
JGames101
Scratcher
100+ posts

My first Scratch Extension

Jonathan50 wrote:

Good job! But the Scratch forums have messed up your code. Instead of using quote tags, you can use code tags (and these display the code in a monospace font so it's easier to read).
Okay, thanks! I'll fix that now.
savaka
Scratcher
1000+ posts

My first Scratch Extension

You can use = to specify the language of the code:
[code=js]
if (variable == 42) {
alert('hello world');
}
[/code]

if (variable == 42) {
    alert('hello world');
}

Also you can use :: to set the type of blocks:
[scratchblocks]
block :: extension
[/scratchblocks]

block :: extension

And submit the extension in the directory if you want. If you don't want to create a GitHub account, post the file on GitHub Gist
JGames101
Scratcher
100+ posts

My first Scratch Extension

savaka wrote:

You can use = to specify the language of the code:
[code=js]
if (variable == 42) {
alert('hello world');
}
[/code]

if (variable == 42) {
    alert('hello world');
}

Also you can use :: to set the type of blocks:
[scratchblocks]
block :: extension
[/scratchblocks]

block :: extension

And submit the extension in the directory if you want. If you don't want to create a GitHub account, post the file on GitHub Gist
Thanks! As I said, I'm very new to making extensions, so this is very helpful.

Powered by DjangoBB