Discuss Scratch

generalbrock2014
Scratcher
8 posts

Creating extensions for Scratch 3.0

extensions that i made
I
I
I
I
v

numbers :: operators
()^() :: operators boolean

Last edited by generalbrock2014 (May 23, 2024 18:37:51)

robot_amelia
Scratcher
56 posts

Creating extensions for Scratch 3.0

I don't understand any of this lol
Acrylylll
Scratcher
10 posts

Creating extensions for Scratch 3.0

Hello everyone. I am making custom extensions. can anyone give me ideas for new extensions?
randomduck42
Scratcher
30 posts

Creating extensions for Scratch 3.0

Acrylylll wrote:

Hello everyone. I am making custom extensions. can anyone give me ideas for new extensions?
an extension that can make the filter bot count every single letter as a swea-

no dont

better make an extension that brings back the old feature that turned lots of numbers into XXXXXXXX's for the users who like privacity
pacmaniacscratch
New Scratcher
31 posts

Creating extensions for Scratch 3.0

when green flag clicked
if <[Your Project] = [ Just a little bit too violent, inappropriate, etc,]> then
switch rating to [NFE]
end

when green flag clicked
if <[Your Project] = [Not a little bit too violent, inappropriate, etc,]> then
switch rating to [FE]
end

Last edited by pacmaniacscratch (June 3, 2024 20:03:17)

julmik6478
Scratcher
500+ posts

Creating extensions for Scratch 3.0

robot_amelia wrote:

I don't understand any of this lol
I recommend you using extension creators.

pacmaniacscratch wrote:

when green flag clicked
if <[Your Project] = [ Just a little bit too violent, inappropriate, etc,]> then
switch rating to [NFE]
end

when green flag clicked
if <[Your Project] = [Not a little bit too violent, inappropriate, etc,]> then
switch rating to [FE]
end
Please don't send non-related to topic blocks here. If you want to just send blocks, use this topic.
igtnathan5
Scratcher
1000+ posts

Creating extensions for Scratch 3.0

i just use custom blocks
The7YearOldGuy
New Scratcher
2 posts

Creating extensions for Scratch 3.0

I am making ChatGPT in scratch so thank you . bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye
Acrylylll
Scratcher
10 posts

Creating extensions for Scratch 3.0

The7YearOldGuy wrote:

I am making ChatGPT in scratch so thank you . bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye bye
its very difficult to make you have to spend a lot of money. i tried to make it myself and i couldnt XD
Charlieonthego
Scratcher
40 posts

Creating extensions for Scratch 3.0


CreateExploreIdeasAbout
Search
39
Charlieonthego

Discuss Scratch

Show new posts since last visit
Discussion Home
Follow Discussion‹‹ previous 1 2 3 4 … 38 39 40 41 next ››
Discussion Forums » Developing Scratch Extensions » Creating extensions for Scratch 3.0
#1Sept. 20, 2017 11:31:05
NitroCipher

Scratcher
500+ posts
Original Poster
Creating extensions for Scratch 3.0
Creating extensions for Scratch 3.0


There is now official documentation regarding extensions!, but feel free to use this post to get you started


You'll want to start off by creating your extension's class, and register the extension - In my case, this would be ‘NitroBlock’

class NitroBlock { //In both instances, NitroBlock will be the name in both instances
}
Scratch.extensions.register(new NitroBlock());

Next, we will be constructing block and menu definitions - We will continue to use ‘NitroBlock’ through this tutorial
getInfo() {
return {
“id”: “NitroBlock”,
“name”: “NitroBlock”,
“blocks”: [
],
“menus”: { //we will get back to this in a later tutorial
}
};
}
Charlieonthego
Scratcher
40 posts

Creating extensions for Scratch 3.0

My extension code:
// create by scratch3-extension generator
const ArgumentType = Scratch.ArgumentType;
const BlockType = Scratch.BlockType;
const formatMessage = Scratch.formatMessage;
const log = Scratch.log;

const menuIconURI = null;
const blockIconURI = null;

class testExt{
constructor (runtime){
this.runtime = runtime;
// communication related
this.comm = runtime.ioDevices.comm;
this.session = null;
this.runtime.registerPeripheralExtension('testExt', this);
// session callbacks
this.reporter = null;
this.onmessage = this.onmessage.bind(this);
this.onclose = this.onclose.bind(this);
this.write = this.write.bind(this);
// string op
this.decoder = new TextDecoder();
this.lineBuffer = '';
}

onclose (){
this.session = null;
}

write (data, parser = null){
if (this.session){
return new Promise(resolve => {
if (parser){
this.reporter = {
parser,
resolve
}
}
this.session.write(data);
})
}
}

onmessage (data){
const dataStr = this.decoder.decode(data);
this.lineBuffer += dataStr;
if (this.lineBuffer.indexOf('\n') !== -1){
const lines = this.lineBuffer.split('\n');
this.lineBuffer = lines.pop();
for (const l of lines){
if (this.reporter){
const {parser, resolve} = this.reporter;
resolve(parser(l));
};
}
}
}

scan (){
this.comm.getDeviceList().then(result => {
this.runtime.emit(this.runtime.constructor.PERIPHERAL_LIST_UPDATE, result);
});
}

getInfo (){
return {
id: 'testExt',
name: 'My Extension',
color1: '#0FBD8C',
color2: '#0DA57A',
menuIconURI: menuIconURI,
blockIconURI: blockIconURI,
blocks: [
{
opcode: 'password',
blockType: BlockType.COMMAND,
arguments: {
password: {
type: ArgumentType.STRING
}
},
text: 'set password to [password]'
},
{
opcode: 'hathook',
blockType: BlockType.HAT,
isEdgeActivated: false,
text: 'when webhook is changed'
},
{
opcode: 'boolean',
blockType: BlockType.BOOLEAN,
arguments: {
synthesizer?: {
type: ArgumentType.BOOLEAN
}
},
text: 'string [synthesizer?] is true'
},
{
opcode: 'stretch',
blockType: BlockType.COMMAND,
arguments: {
100: {
type: ArgumentType.STRING
}
},
text: 'stretch [100]'
},
{
opcode: 'script',
blockType: BlockType.COMMAND,
arguments: {
text: {
type: ArgumentType.STRING
}
},
text: 'script name [text]'
},
{
opcode: 'control_encodetonumbers',
blockType: BlockType.COMMAND,
arguments: {
text: {
type: ArgumentType.STRING
}
},
text: 'number encoding as [text]'
},
{
opcode: 'debugger_breakpoint',
blockType: BlockType.COMMAND,
text: 'debug window'
},
{
opcode: 'control_repeat',
blockType: BlockType.COMMAND,
arguments: {
number: {
type: ArgumentType.STRING
}
},
text: 'my repeat [number]'
},
{
opcode: 'report',
blockType: BlockType.COMMAND,
arguments: {
string: {
type: ArgumentType.STRING
}
},
text: 'return [string]'
},
{
opcode: 'control_makefile',
blockType: BlockType.COMMAND,
text: 'create file'
},
{
opcode: 'define',
blockType: BlockType.HAT,
isEdgeActivated: false,
arguments: {
text: {
type: ArgumentType.STRING
}
},
text: 'define [text]'
},
{
opcode: 'hat',
blockType: BlockType.HAT,
isEdgeActivated: false,
arguments: {
boolean: {
type: ArgumentType.BOOLEAN
}
},
text: 'when [boolean]'
},
{
opcode: 'animatedtext_setfont',
blockType: BlockType.COMMAND,
arguments: {
font: {
type: ArgumentType.STRING
}
},
text: 'set font to [font]'
},
{
opcode: 'coreex_exampleblock',
blockType: BlockType.REPORTER,
text: 'example block'
},
{
opcode: 'custom_squarebox',
blockType: BlockType.COMMAND,
text: '0.1 block'
},
{
opcode: 'hue_css',
blockType: BlockType.COMMAND,
arguments: {
css: {
type: ArgumentType.STRING
}
},
text: 'CSS file breaker [css]'
},
{
opcode: 'substringy',
blockType: BlockType.REPORTER,
arguments: {
num1: {
type: ArgumentType.STRING
},
num2: {
type: ArgumentType.STRING
},
string: {
type: ArgumentType.STRING
}
},
text: 'letters [num1] to [num2] of [string]'
},
{
opcode: 'block_script',
blockType: BlockType.COMMAND,
text: 'block script'
},
{
opcode: 'control_useselection',
blockType: BlockType.COMMAND,
arguments: {
text1: {
type: ArgumentType.STRING
},
text2: {
type: ArgumentType.STRING
}
},
text: 'query replace [text1] with [text2]'
},
{
opcode: 'procedures_prototype',
blockType: BlockType.HAT,
isEdgeActivated: false,
arguments: {
undefined text: {
type: ArgumentType.STRING
}
},
text: 'name block [undefined text]'
},
{
opcode: 'extension_isturbowarp',
blockType: BlockType.BOOLEAN,
text: 'is TurboWarp?'
},
{
opcode: 'sensing_setusername',
blockType: BlockType.COMMAND,
arguments: {
username: {
type: ArgumentType.STRING
}
},
text: 'set username to [username]'
},
{
opcode: 'index',
blockType: BlockType.COMMAND,
arguments: {
code: {
type: ArgumentType.STRING
}
},
text: 'file index JavaScript [code]'
}
]
}
}

password (args, util){
const password = args.password;

return this.write(`M0 \n`);
}

hathook (args, util){

return this.write(`M0 \n`);
}

boolean (args, util){
const synthesizer? = args.synthesizer?;

return this.write(`M0 \n`);
}

stretch (args, util){
const 100 = args.100;

return this.write(`M0 \n`);
}

script (args, util){
const text = args.text;

return this.write(`M0 \n`);
}

control_encodetonumbers (args, util){
const text = args.text;

return this.write(`M0 \n`);
}

debugger_breakpoint (args, util){

return this.write(`M0 \n`);
}

control_repeat (args, util){
const number = args.number;

return this.write(`M0 \n`);
}

report (args, util){
const string = args.string;

return this.write(`M0 \n`);
}

control_makefile (args, util){

return this.write(`M0 \n`);
}

define (args, util){
const text = args.text;

return this.write(`M0 \n`);
}

hat (args, util){
const boolean = args.boolean;

return this.write(`M0 \n`);
}

animatedtext_setfont (args, util){
const font = args.font;

return this.write(`M0 \n`);
}

coreex_exampleblock (args, util){

return this.write(`M0 \n`);
}

custom_squarebox (args, util){

return this.write(`M0 \n`);
}

hue_css (args, util){
const css = args.css;

return this.write(`M0 \n`);
}

substringy (args, util){
const num1 = args.num1;
const num2 = args.num2;
const string = args.string;

return this.write(`M0 \n`);
}

block_script (args, util){

return this.write(`M0 \n`);
}

control_useselection (args, util){
const text1 = args.text1;
const text2 = args.text2;

return this.write(`M0 \n`);
}

procedures_prototype (args, util){
const undefined text = args.undefined text;

return this.write(`M0 \n`);
}

extension_isturbowarp (args, util){

return this.write(`M0 \n`);
}

sensing_setusername (args, util){
const username = args.username;

return this.write(`M0 \n`);
}

index (args, util){
const code = args.code;

return this.write(`M0 \n`);
}

}

module.exports = testExt;
[/code]
THE_diamond_2021cat
Scratcher
24 posts

Creating extensions for Scratch 3.0

when I get back to this topic :: control hat
say [i havent been here for a long time now]
repeat :: control cap
tugael06
Scratcher
46 posts

Creating extensions for Scratch 3.0

MAXI EXTENSIONS:

Portuguese Language:

main country (Brazil)
tugael06
Scratcher
46 posts

Creating extensions for Scratch 3.0

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEE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RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
Please don't spam
MishkaGamesFun
Scratcher
3 posts

Creating extensions for Scratch 3.0

try my project, it has almost all extensions: https://scratch.mit.edu/projects/955635256/
SleepyWeppyTK122
Scratcher
11 posts

Creating extensions for Scratch 3.0

If only there were extensions like
set minecraft  block color to [#ff0000]
SleepyWeppyTK122
Scratcher
11 posts

Creating extensions for Scratch 3.0

Charlieonthego wrote:

My extension code:
// create by scratch3-extension generator
const ArgumentType = Scratch.ArgumentType;
const BlockType = Scratch.BlockType;
const formatMessage = Scratch.formatMessage;
const log = Scratch.log;

const menuIconURI = null;
const blockIconURI = null;

class testExt{
constructor (runtime){
this.runtime = runtime;
// communication related
this.comm = runtime.ioDevices.comm;
this.session = null;
this.runtime.registerPeripheralExtension('testExt', this);
// session callbacks
this.reporter = null;
this.onmessage = this.onmessage.bind(this);
this.onclose = this.onclose.bind(this);
this.write = this.write.bind(this);
// string op
this.decoder = new TextDecoder();
this.lineBuffer = '';
}

onclose (){
this.session = null;
}

write (data, parser = null){
if (this.session){
return new Promise(resolve => {
if (parser){
this.reporter = {
parser,
resolve
}
}
this.session.write(data);
})
}
}

onmessage (data){
const dataStr = this.decoder.decode(data);
this.lineBuffer += dataStr;
if (this.lineBuffer.indexOf('\n') !== -1){
const lines = this.lineBuffer.split('\n');
this.lineBuffer = lines.pop();
for (const l of lines){
if (this.reporter){
const {parser, resolve} = this.reporter;
resolve(parser(l));
};
}
}
}

scan (){
this.comm.getDeviceList().then(result => {
this.runtime.emit(this.runtime.constructor.PERIPHERAL_LIST_UPDATE, result);
});
}

getInfo (){
return {
id: 'testExt',
name: 'My Extension',
color1: '#0FBD8C',
color2: '#0DA57A',
menuIconURI: menuIconURI,
blockIconURI: blockIconURI,
blocks: [
{
opcode: 'password',
blockType: BlockType.COMMAND,
arguments: {
password: {
type: ArgumentType.STRING
}
},
text: 'set password to [password]'
},
{
opcode: 'hathook',
blockType: BlockType.HAT,
isEdgeActivated: false,
text: 'when webhook is changed'
},
{
opcode: 'boolean',
blockType: BlockType.BOOLEAN,
arguments: {
synthesizer?: {
type: ArgumentType.BOOLEAN
}
},
text: 'string [synthesizer?] is true'
},
{
opcode: 'stretch',
blockType: BlockType.COMMAND,
arguments: {
100: {
type: ArgumentType.STRING
}
},
text: 'stretch [100]'
},
{
opcode: 'script',
blockType: BlockType.COMMAND,
arguments: {
text: {
type: ArgumentType.STRING
}
},
text: 'script name [text]'
},
{
opcode: 'control_encodetonumbers',
blockType: BlockType.COMMAND,
arguments: {
text: {
type: ArgumentType.STRING
}
},
text: 'number encoding as [text]'
},
{
opcode: 'debugger_breakpoint',
blockType: BlockType.COMMAND,
text: 'debug window'
},
{
opcode: 'control_repeat',
blockType: BlockType.COMMAND,
arguments: {
number: {
type: ArgumentType.STRING
}
},
text: 'my repeat [number]'
},
{
opcode: 'report',
blockType: BlockType.COMMAND,
arguments: {
string: {
type: ArgumentType.STRING
}
},
text: 'return [string]'
},
{
opcode: 'control_makefile',
blockType: BlockType.COMMAND,
text: 'create file'
},
{
opcode: 'define',
blockType: BlockType.HAT,
isEdgeActivated: false,
arguments: {
text: {
type: ArgumentType.STRING
}
},
text: 'define [text]'
},
{
opcode: 'hat',
blockType: BlockType.HAT,
isEdgeActivated: false,
arguments: {
boolean: {
type: ArgumentType.BOOLEAN
}
},
text: 'when [boolean]'
},
{
opcode: 'animatedtext_setfont',
blockType: BlockType.COMMAND,
arguments: {
font: {
type: ArgumentType.STRING
}
},
text: 'set font to [font]'
},
{
opcode: 'coreex_exampleblock',
blockType: BlockType.REPORTER,
text: 'example block'
},
{
opcode: 'custom_squarebox',
blockType: BlockType.COMMAND,
text: '0.1 block'
},
{
opcode: 'hue_css',
blockType: BlockType.COMMAND,
arguments: {
css: {
type: ArgumentType.STRING
}
},
text: 'CSS file breaker [css]'
},
{
opcode: 'substringy',
blockType: BlockType.REPORTER,
arguments: {
num1: {
type: ArgumentType.STRING
},
num2: {
type: ArgumentType.STRING
},
string: {
type: ArgumentType.STRING
}
},
text: 'letters [num1] to [num2] of [string]'
},
{
opcode: 'block_script',
blockType: BlockType.COMMAND,
text: 'block script'
},
{
opcode: 'control_useselection',
blockType: BlockType.COMMAND,
arguments: {
text1: {
type: ArgumentType.STRING
},
text2: {
type: ArgumentType.STRING
}
},
text: 'query replace [text1] with [text2]'
},
{
opcode: 'procedures_prototype',
blockType: BlockType.HAT,
isEdgeActivated: false,
arguments: {
undefined text: {
type: ArgumentType.STRING
}
},
text: 'name block [undefined text]'
},
{
opcode: 'extension_isturbowarp',
blockType: BlockType.BOOLEAN,
text: 'is TurboWarp?'
},
{
opcode: 'sensing_setusername',
blockType: BlockType.COMMAND,
arguments: {
username: {
type: ArgumentType.STRING
}
},
text: 'set username to [username]'
},
{
opcode: 'index',
blockType: BlockType.COMMAND,
arguments: {
code: {
type: ArgumentType.STRING
}
},
text: 'file index JavaScript [code]'
}
]
}
}

password (args, util){
const password = args.password;

return this.write(`M0 \n`);
}

hathook (args, util){

return this.write(`M0 \n`);
}

boolean (args, util){
const synthesizer? = args.synthesizer?;

return this.write(`M0 \n`);
}

stretch (args, util){
const 100 = args.100;

return this.write(`M0 \n`);
}

script (args, util){
const text = args.text;

return this.write(`M0 \n`);
}

control_encodetonumbers (args, util){
const text = args.text;

return this.write(`M0 \n`);
}

debugger_breakpoint (args, util){

return this.write(`M0 \n`);
}

control_repeat (args, util){
const number = args.number;

return this.write(`M0 \n`);
}

report (args, util){
const string = args.string;

return this.write(`M0 \n`);
}

control_makefile (args, util){

return this.write(`M0 \n`);
}

define (args, util){
const text = args.text;

return this.write(`M0 \n`);
}

hat (args, util){
const boolean = args.boolean;

return this.write(`M0 \n`);
}

animatedtext_setfont (args, util){
const font = args.font;

return this.write(`M0 \n`);
}

coreex_exampleblock (args, util){

return this.write(`M0 \n`);
}

custom_squarebox (args, util){

return this.write(`M0 \n`);
}

hue_css (args, util){
const css = args.css;

return this.write(`M0 \n`);
}

substringy (args, util){
const num1 = args.num1;
const num2 = args.num2;
const string = args.string;

return this.write(`M0 \n`);
}

block_script (args, util){

return this.write(`M0 \n`);
}

control_useselection (args, util){
const text1 = args.text1;
const text2 = args.text2;

return this.write(`M0 \n`);
}

procedures_prototype (args, util){
const undefined text = args.undefined text;

return this.write(`M0 \n`);
}

extension_isturbowarp (args, util){

return this.write(`M0 \n`);
}

sensing_setusername (args, util){
const username = args.username;

return this.write(`M0 \n`);
}

index (args, util){
const code = args.code;

return this.write(`M0 \n`);
}

}

module.exports = testExt;
[/code][/quote]can you tell me what the block looks like?
Gamelovinggamer
Scratcher
93 posts

Creating extensions for Scratch 3.0

NitroCipher wrote:

Creating extensions for Scratch 3.0


There is now official documentation regarding extensions!, but feel free to use this post to get you started


You'll want to start off by creating your extension's class, and register the extension - In my case, this would be ‘NitroBlock’

class NitroBlock { //In both instances, NitroBlock will be the name in both instances
}
Scratch.extensions.register(new NitroBlock());

Next, we will be constructing block and menu definitions - We will continue to use ‘NitroBlock’ through this tutorial
getInfo() {
    return {
        "id": "NitroBlock",
        "name": "NitroBlock",
        "blocks": [
        ],
        "menus": { //we will get back to this in a later tutorial
        }
    };
}

We are going to take a look at how blocks are constructed

For those of you that are familiar with extensions for Scratch 2.0, we will start off with this: - If not, you can ignore this
['r', 'letters %n through %n of %s', 'substringy', '2', '5', 'hello world']
//breakdown below:
['r' = block type, 'letters %n through %n of %s' = block text, 'substringy' = block ID/opcode]

{
    "opcode": "substringy", //This will be the ID code for the block
    "blockType": "reporter", //This can either be Boolean, reporter, command, or hat
    "text": "letters [num1] through [num2] of [string]", //This is the block text, and how it will display in the Scratch interface
    "arguments": { //Arguments are the input fields in the block. In the block text, place arguments in square brackets with the corresponding ID 
        "num1": { //This is the ID for your argument
            "type": "number", //This can be either Boolean, number, or string
            "defaultValue": "2" //This is the default text that will appear in the input field, you can leave this blank if you wish
        },
        "num2": {
            "type": "number",
            "defaultValue": "5"
        },
        "string": {
            "type": "string",
            "defaultValue": "hello world"
        }
    }
},

We will put this newly constructed code into the blocks object above - My code will now look like this
class NitroBlock {
    getInfo() {
        return {
            "id": "NitroBlock",
            "name": "NitroBlock",
            "blocks": [{
                    "opcode": "substringy",
                    "blockType": "reporter",
                    "text": "letters [num1] through [num2] of [string]",
                    "arguments": {
                        "num1": {
                            "type": "number",
                            "defaultValue": "2"
                        },
                        "num2": {
                            "type": "number",
                            "defaultValue": "5"
                        },
                        "string": {
                            "type": "string",
                            "defaultValue": "hello world"
                        }
                    }
                },
            }],
        "menus": { //we will get back to this in a later tutorial
        }
    };
}
Scratch.extensions.register(new NitroBlock());

Next we come to the most important part, the code that actually runs the blocks! - I am keeping this short and simple for tutorial's sake.
//Make sure you name this function with with the proper ID for the block you defined above
substringy({num1, num2, string}) { //these names will match the argument names you used earlier, and will be used as the variables in your code
    //this code can be anything you want
    return string.substring(num1 - 1, num2);  //for reporters and Boolean blocks the important thing is to use 'return' to get the value back into Scratch.
}

Place this new code below your getInfo() function
class NitroBlock {
    getInfo() {
        return {
            "id": "NitroBlock",
            "name": "NitroBlock",
            "blocks": [{
                    "opcode": "substringy",
                    "blockType": "reporter",
                    "text": "letters [num1] through [num2] of [string]",
                    "arguments": {
                        "num1": {
                            "type": "number",
                            "defaultValue": "2"
                        },
                        "num2": {
                            "type": "number",
                            "defaultValue": "5"
                        },
                        "string": {
                            "type": "string",
                            "defaultValue": "hello world"
                        }
                    }
                },
            }],
        "menus": { //we will get back to this in a later tutorial
        }
    };
    substringy({num1, num2, string}) {
        return string.substring(num1 - 1, num2);
    };
}

Save this code to your computer as a js file, in my case it is NitroBlock_3.js

Congratz, you now have your extension code created!!
You can use this tutorial to add it your own personal copy of scratch
Or, you can host the extension with gh-pages, and go here to test it
(provide your own url, don't use mine)

Here is the archived copy of my original post

is that supposed to be making a block? btw i dont understand, if you posted a project with that block and someone without the extension played it, what would happen?
THE_diamond_2021cat
Scratcher
24 posts

Creating extensions for Scratch 3.0

rest for (idk why im still here tbh) beats

Powered by DjangoBB