Discuss Scratch

donotforgetmycode
Scratcher
100+ posts

My Scratch Extension

How to link to another website on Scratch
Step 1:
Highlight the code below and press Ctrl+C or right-click and select Copy.
(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(website) {
window.location.href = website;
};

// Block and block menu descriptions
var descriptor = {
blocks: [
// Block type, block name, function name
[' ', 'link to %s', 'my_first_block', 'https://scratch.mit.edu'],
]
};

// Register the extension
ScratchExtensions.register('Link', descriptor, ext);
})({});
Step 2:
Go to Scratch and press Ctrl+Shift+J.
Press Ctrl+V or right-click and select Paste.
Step 3:
Click More Blocks. You should see this block:
link to [https://scratch.mit.edu]
Use the block!

Ho guys.
;
herohamp
Scratcher
1000+ posts

My Scratch Extension

donotforgetmycode
Scratcher
100+ posts

My Scratch Extension

herohamp wrote:

Wrong forum…………………..
My I teach you about /discuss/48?
https://scratch.mit.edu/discuss/48/
Oops, sorry
I think it has been moved though.

Last edited by donotforgetmycode (Aug. 15, 2017 08:26:09)


Ho guys.
;
JGames101
Scratcher
100+ posts

My Scratch Extension

donotforgetmycode wrote:

How to link to another website on Scratch
Step 1:
Highlight the code below and press Ctrl+C or right-click and select Copy.
(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(website) {
window.location.href = website;
};

// Block and block menu descriptions
var descriptor = {
blocks: [
// Block type, block name, function name
[' ', 'link to %s', 'my_first_block', 'https://scratch.mit.edu'],
]
};

// Register the extension
ScratchExtensions.register('Link', descriptor, ext);
})({});
Step 2:
Go to Scratch and press Ctrl+Shift+J.
Press Ctrl+V or right-click and select Paste.
Step 3:
Click More Blocks. You should see this block:
link to [https://scratch.mit.edu]
Use the block!
This is great! I remember my first extension was just true and false blocks…
Here are a few tips for your forum post, though:
instead of having your block look like
link to [https://scratch.mit.edu]
link to [https://scratch.mit.edu]
You can do
link to [https://scratch.mit.edu] :: extension
link to [https://scratch.mit.edu] :: extension
Just to make it look better
Another thing you can do is instead of using
[code]
[/code]
You can do
[code=javascript]
[/code]
And instead of being all grey, it makes the text look like
(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(website) {
        window.location.href = website;
    };
    // Block and block menu descriptions
    var descriptor = {
        blocks: [
            // Block type, block name, function name
            [' ', 'link to %s', 'my_first_block', 'https://scratch.mit.edu'],
        ]
    };
    // Register the extension
    ScratchExtensions.register('Link', descriptor, ext);
})({});
So it's easier to understand. Anyway, great extension, and I look forward to seeing what you create in the future


I have been away from Scratch for a while, programming in JavaScript, Dart, C++, and Rust.

I won't make any more Scratch Projects, but I'll be on the forums talking about Scratch 3 Modding and Extensions.

Scratch 3 Modding
donotforgetmycode
Scratcher
100+ posts

My Scratch Extension

JGames101 wrote:

This is great! I remember my first extension was just true and false blocks…
Here are a few tips for your forum post, though:
instead of having your block look like
link to [https://scratch.mit.edu]
link to [https://scratch.mit.edu]
You can do
link to [https://scratch.mit.edu] :: extension
link to [https://scratch.mit.edu] :: extension
Just to make it look better
Another thing you can do is instead of using
[code]
[/code]
You can do
[code=javascript]
[/code]
And instead of being all grey, it makes the text look like
(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(website) {
        window.location.href = website;
    };
    // Block and block menu descriptions
    var descriptor = {
        blocks: [
            // Block type, block name, function name
            [' ', 'link to %s', 'my_first_block', 'https://scratch.mit.edu'],
        ]
    };
    // Register the extension
    ScratchExtensions.register('Link', descriptor, ext);
})({});
So it's easier to understand. Anyway, great extension, and I look forward to seeing what you create in the future
Thank you

Last edited by donotforgetmycode (Aug. 20, 2017 12:55:34)


Ho guys.
;
jackkillian
Scratcher
24 posts

My Scratch Extension

You said go to Scratch and press Control+Shift+J.
The Scratch homepage or the Scratch project editor.

Last edited by jackkillian on March 9, 9999
#Bring_it_Back
Hi, and welcome to Scratch! Click Here to go to the Scratch home page.
jackkillian
Scratcher
24 posts

My Scratch Extension

My browser / operating system: MacOS Macintosh X 10.12.5, Chrome 60.0.3112.101, Flash 26.0 (release 0)
Not working for me on either.

Last edited by jackkillian on March 9, 9999
#Bring_it_Back
Hi, and welcome to Scratch! Click Here to go to the Scratch home page.
donotforgetmycode
Scratcher
100+ posts

My Scratch Extension

jackkillian wrote:

My browser / operating system: MacOS Macintosh X 10.12.5, Chrome 60.0.3112.101, Flash 26.0 (release 0)
Not working for me on either.
Try holding cmd instead of ctrl in the project editor. Do not do anything on the editor, otherwise the JavaScript console will not appear. ☺

Ho guys.
;
donotforgetmycode
Scratcher
100+ posts

My Scratch Extension

bump

Ho guys.
;

Powered by DjangoBB

Standard | Mobile