Discuss Scratch

Elliot3-0
Scratcher
88 posts

Creating extensions for Scratch 3.0

some random guy said
i will get you at 3am

Highlight signature, then press shift+down arrow key(hold down the down arrow key) to see my full signature!
when green flag clicked
say [Thank you for reading this post!]
My Stats
My Profile
Scratch Minigames

when I [ figure out someone hacked my project to be a rickroll]
turn on [ rickroll destroyer ∞]
take that hackers no more rickrolls >:D
today i found a evil kumquat so i stepped on it
is it christmas time yet?
∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ thx for reading ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
hold it! illuminati? *plays wilheim scream while i jump to the secret bunker at the core of Mars*
ok signing off
gets into Smash Bros. Flaw
LESS GOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
Ok i am signing off 4 real i 3 2 1 *computer shuts off and explodes* NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
jk lol
cats = :cool:
when green flag clicked
go to [ computer graveyard lol why am i writing this]
set [ sadness] to [ remorse]
signing off now (lol)
THE_diamond_2021cat
Scratcher
21 posts

Creating extensions for Scratch 3.0

when <hat (when I move [10] steps :: hat :: motion) ran :: operators> :: hat :: events
figure out [how to make blocks inside blocks v] :: sensing
run hat (when green flag clicked :: hat) :: control


forever if <variable (when green flag clicked) exists? :: operators> :: control
joe
else
jimmy
else
john
else
joey
else
jacobson
end

꧁•⊹٭The King of Diamondland٭⊹•꧂
Cool_Drum
New to Scratch
1 post

Creating extensions for Scratch 3.0

when green flag clicked
when green flag clicked
megastudios_keegan
New to Scratch
28 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
how do you get to the place to make them
Boss_1s
Scratcher
100+ posts

Creating extensions for Scratch 3.0

I tried npm install in the terminal but it gave me the following error:

> scratch-blocks@0.1.0 prepublish
> python build.py && webpack

Traceback (most recent call last):
File “/workspaces/scratch-blocks/scratch-blocks/build.py”, line 39, in <module>
raise Exception(“Blockly build only compatible with Python 2.x.\n”
Exception: Blockly build only compatible with Python 2.x.
You are using: 3.10.8 (main, Oct 5 2023, 20:05:15)
npm ERR! code 1
npm ERR! path /workspaces/scratch-blocks/scratch-blocks
npm ERR! command failed
npm ERR! command sh -c python build.py && webpack

npm ERR! A complete log of this run can be found in: /home/codespace/.npm/_logs/2023-10-20T17_34_08_713Z-debug-0.log

My browser / operating system: ChromeOS 14816.131.0, Chrome 103.0.0.0, No Flash version detected
I have already git cloned the …/google/closure-library repo on Github Codespace.

Do <Highlight+shift+down arrow ::sensing> to see the rest of my signature. ::hat :: events

Generation 11: the first time you see this copy and paste it on top of your signature in the scratch forums and increase generation by 1. Social experiment.


Support the suggestion HERE by adding this button to your signature


Blocks Scratch should have:
substring [letter#1] [letter#2] [string] ::operators //finds the string between a string
pause [this script v] for (1) seconds ::control
(() or ()::operators)
(() and ()::operators) //same as the boolean, but for reporting
<my boolean ::variables> //only stores true or false
show all variables::variables
hide all variable::variables
show all lists::list
hide all lists::list
…and more!

Alt accounts: @Boss_1sALT(for cloud testing and other stuff), @Boss_1sARCHIVE(Archive of older game versions)

Hi, my name is @Boss_1s!
I'm 12 years old, and I joined Scratch to relearn block coding.
Other projects:
https://scratch.mit.edu/projects/869604293/ - cool MMO platformer
https://scratch.mit.edu/projects/792424859/ - This is my first ORIGINAL game.
https://scratch.mit.edu/projects/914686250/ - NEW! Remixed an RPG from Griffpatch, though it's pretty boring right now…
https://scratch.mit.edu/projects/895107188/ - NEW! Safe chat with anyone on Scratch, whitelist is present
Secret Special Advanced Project (SSAdP): COMPLETED!!! https://scratch.mit.edu/projects/946720515/

Predominant Languages:
I speak American English and Chinese.
我說美文和中文。

That's all for my signature, folks! cya!
SteveMart5
Scratcher
13 posts

Creating extensions for Scratch 3.0

beter blocks
when [ enter] key pressed
define <drop downs v>[numbers]
if <true v> then

end
ExpungleCat2023
Scratcher
12 posts

Creating extensions for Scratch 3.0

i thought this was dead ;-;

start sound [cave_noise v] :: sound hat
if <when flag clicked> then
run hat (move (10) steps :: hat) :: custom
pause [your mom v] for [a dillion] seconds :: control
end

My name is Maxx. I was the loyal “pet” cat to Expunged, but I ran away. Want to join the Expunged Empire? Sign up here: https://scratch.mit.edu/projects/822961685
add [Expunged] to [Peeps i ran away from v]
rivan2
Scratcher
17 posts

Creating extensions for Scratch 3.0

What language is this written in?
flappiepapie
Scratcher
3 posts

Creating extensions for Scratch 3.0

They Should Make a Text Engine Extension
khilfimango555
Scratcher
13 posts

Creating extensions for Scratch 3.0

define (define(define))
define
(join [define] [])
khilfimango555
Scratcher
13 posts

Creating extensions for Scratch 3.0

play sound [cave_noise_minecraft.mp3]
if <when green flag clicked> then
Run hat <move 10 steps>
win889888
Scratcher
21 posts

Creating extensions for Scratch 3.0

<can we have more simple version plz also can it support Mac>

Last edited by win889888 (Dec. 25, 2023 16:46:05)

Elliot3-0
Scratcher
88 posts

Creating extensions for Scratch 3.0

when green flag clicked
draw with pen [...]

we need this block

Last edited by Elliot3-0 (Dec. 25, 2023 16:52:17)


Highlight signature, then press shift+down arrow key(hold down the down arrow key) to see my full signature!
when green flag clicked
say [Thank you for reading this post!]
My Stats
My Profile
Scratch Minigames

when I [ figure out someone hacked my project to be a rickroll]
turn on [ rickroll destroyer ∞]
take that hackers no more rickrolls >:D
today i found a evil kumquat so i stepped on it
is it christmas time yet?
∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞ thx for reading ∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
hold it! illuminati? *plays wilheim scream while i jump to the secret bunker at the core of Mars*
ok signing off
gets into Smash Bros. Flaw
LESS GOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
Ok i am signing off 4 real i 3 2 1 *computer shuts off and explodes* NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
jk lol
cats = :cool:
when green flag clicked
go to [ computer graveyard lol why am i writing this]
set [ sadness] to [ remorse]
signing off now (lol)
idkwhattomake1122123
Scratcher
2 posts

Creating extensions for Scratch 3.0

¿
legoscode
Scratcher
25 posts

Creating extensions for Scratch 3.0

is there any good places to test out custom extensions other than sheeptesters mod and turbowarp?

- legoscode,
StorageOS

Artist StorageOS team
tugael06
Scratcher
44 posts

Creating extensions for Scratch 3.0

I don't know, But get away from my face
Let's make a dance block
First use this code:
when green flag clicked
forever

move (34) stepsend
change y by (8)
glide (1) secs to x: (0) y: (0)

Now click the Green flag button to start dancing forever!
tugael06
Scratcher
44 posts

Creating extensions for Scratch 3.0

Let's make a block!
Use this block
define

change y by (input)
glide (1) secs to x: (x position) y: (0)
tugael06
Scratcher
44 posts

Creating extensions for Scratch 3.0

Great! use the code

jump (37)
tugael06
Scratcher
44 posts

Creating extensions for Scratch 3.0

Pablo:
say [(5+34)] for (4.2) secs
tugael06
Scratcher
44 posts

Creating extensions for Scratch 3.0

Masha:
Good job Pablo! you said 39!
Also me:
forever

stamp

Powered by DjangoBB