Discuss Scratch

PullJosh
Scratcher
1000+ posts

My First Extension!

I'm not sure if this should go in MaC. If it should, somebody report this please.

I've been messing around with the (somewhat) new experimental extensions. I've made one with some blocks I think would be useful for many projects. Currently, because of the way the beta is set up, projects that use these blocks can't be shared, but they can be saved for your own enjoyment.

You can find a list of all the blocks in this extension here.

Want to try these blocks out for yourself? Here's how:
Open the Scratch editor.
Hold down the shift key, and click the file button.
Click “Import experimental extension”
Paste in this url: http://pulljosh.github.io/extensions/rawcode/EverythingExtension.js

Go to “More blocks” and try them out!
Remember, you can't share projects created with these.


Have an idea for another block? A tip for how to simplify my code? Let me know!


Edit: I've added a TON more blocks.

Last edited by PullJosh (July 11, 2014 17:55:30)

djdolphin
Scratcher
1000+ posts

My First Extension!

You should probably make “Alert” lowercase to match every other Scratch blocks that ever existed (Except Scratch days). And don't use eval - I used to make this mistake myself. People can execute any code they want, so it could easily be abused.

Last edited by djdolphin (June 6, 2014 22:45:15)


!
PullJosh
Scratcher
1000+ posts

My First Extension!

djdolphin wrote:

You should probably make “Alert” lowercase to match every other Scratch blocks that ever existed (Except Scratch days). And don't use eval - I used to make this mistake myself. People can execute any code they want, so it could easily be abused.
1) Good point. I'll do that someday when I'm not feeling to lazy.
2) Really? Good to know. Do you know of any alternatives?

Edit: Would this work? (Just cleaning up the string first)

Last edited by PullJosh (June 6, 2014 23:23:36)

savaka
Scratcher
1000+ posts

My First Extension!

Nice extension! Handy, especially the exponent. Here's my extension.
savaka
Scratcher
1000+ posts

My First Extension!

I made this extension place thing here. Can I add your extension to it?
Braeden5454
Scratcher
500+ posts

My First Extension!

the factorial appears as %n factorial on the screen.

No text here-> Haha April Fools, You spent 3 seconds highlighting this.
move () steps

If you think my post was helpful, you may want to Follow me to receive updated and useful tips.
I am raeden5454. You can check out some more projects at My Prof
404 Error. Cannot find page “signature”. Reason: Kumquat consumption
Blueinkproductions
Scratcher
1000+ posts

My First Extension!

This is pretty dangerous… You can forever open a new tab… and then things go down the tubes

Generation 2: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.
____                  _____  _______              
| \ | | | | | |\ | | /
|___/ | | | |__ | | \ | |/
| \ | | | | | | \ | |\
| | | | | | | | \ | | \
|___/ L____ \___/ |_____ ___|___ | \| | \
PRODUCTIONS





















































Here's a hint: support = support.

<shameless self promotion>follow me! follow me! follow me! love my stuff! love my stuff! love my stuff! follow me! love my stuff! remix my stuff! follow me! follow me! </shameless self promotion>
PullJosh
Scratcher
1000+ posts

My First Extension!

Blueinkproductions wrote:

This is pretty dangerous… You can forever open a new tab… and then things go down the tubes
Meh. I'm just playing with stuff. If I try to submit it, I won't include those blocks.
PullJosh
Scratcher
1000+ posts

My First Extension!

savaka wrote:

I made this extension place thing here. Can I add your extension to it?
Sure!

Braeden5454 wrote:

the factorial appears as %n factorial on the screen.
Yes. I can't figure out how to remove the checkbox.
Braeden5454
Scratcher
500+ posts

My First Extension!

PullJosh wrote:

savaka wrote:

I made this extension place thing here. Can I add your extension to it?
Sure!

Braeden5454 wrote:

the factorial appears as %n factorial on the screen.
Yes. I can't figure out how to remove the checkbox.
Didn't you do that on another block?

No text here-> Haha April Fools, You spent 3 seconds highlighting this.
move () steps

If you think my post was helpful, you may want to Follow me to receive updated and useful tips.
I am raeden5454. You can check out some more projects at My Prof
404 Error. Cannot find page “signature”. Reason: Kumquat consumption
PullJosh
Scratcher
1000+ posts

My First Extension!

Braeden5454 wrote:

PullJosh wrote:

savaka wrote:

I made this extension place thing here. Can I add your extension to it?
Sure!

Braeden5454 wrote:

the factorial appears as %n factorial on the screen.
Yes. I can't figure out how to remove the checkbox.
Didn't you do that on another block?
It automatically adds it to some blocks but not others. I don't know what they are, so I can't stop meeting them. xD
nathanprocks
Scratcher
1000+ posts

My First Extension!

PullJosh wrote:

Braeden5454 wrote:

PullJosh wrote:

savaka wrote:

I made this extension place thing here. Can I add your extension to it?
Sure!

Braeden5454 wrote:

the factorial appears as %n factorial on the screen.
Yes. I can't figure out how to remove the checkbox.
Didn't you do that on another block?
It automatically adds it to some blocks but not others. I don't know what they are, so I can't stop meeting them. xD
I don't know about 2.0, but 1.4 removed the checkbox for reporter blocks that contain certain strings. I am guessing that 2.0 also does that.


My browser / operating system: Macrosoft Winding XO, Internet Exploder 6.0, Angel Player ver.:1.2.5
;
nathanprocks
Scratcher
1000+ posts

My First Extension!

You should replace some of the ‘if’ statements to ‘switch’ because it make code easier to read and update.
// Instead of this
if (pie == 'pi') {
    return Math.PI;
} else if (pie == 'e') {
    return Math.E;
} else {
    return;
}
// Use this
switch(pie) {
    case 'pi':
        return Math.PI;
        break;
    case 'e':
        return Math.E;
        break;
    default:
        return;
}
// Instead of this
if (engine == 'Google') {
    window.open('http://www.google.com/search?q=' + realquery, '_blank').focus();
} else if (engine == 'Duck Duck Go') {
    window.open('http://www.duckduckgo.com/?q=' + realquery, '_blank').focus();
} else if (engine == 'Bing') {
    window.open('http://bing.com/search?q=' + realquery, '_blank').focus();
} else if (engine == 'Ask') {
    window.open('http://ask.com/web?q=' + realquery, '_blank').focus();
} else if (engine == 'Yahoo') {
    window.open('http://search.yahoo.com/search?q=' + realquery + '&fr=sfp', '_blank').focus();
} else {
    return;
}
// Use this
switch(engine) {
    case 'Google':
        window.open('http://www.google.com/search?q=' + realquery, '_blank').focus();
        break;
    case 'Duck Duck Go':
        window.open('http://www.duckduckgo.com/?q=' + realquery, '_blank').focus();
        break;
    case 'Bing':
        window.open('http://bing.com/search?q=' + realquery, '_blank').focus();
        break;
    case 'Ask':
        window.open('http://ask.com/web?q=' + realquery, '_blank').focus();
        break;
    case 'Yahoo':
        window.open('http://search.yahoo.com/search?q=' + realquery + '&fr=sfp', '_blank').focus();
        break;
    default:
        return;
}

Last edited by nathanprocks (July 11, 2014 05:36:07)



My browser / operating system: Macrosoft Winding XO, Internet Exploder 6.0, Angel Player ver.:1.2.5
;
PullJosh
Scratcher
1000+ posts

My First Extension!

nathanprocks wrote:

You should replace some of the ‘if’ statements to ‘switch’ because it make code easier to read and update.
Okay, thanks! I didn't know about that.
(Well, actually, I vaguely remember seeing it a few years ago, but…)
nXIII
Scratcher
1000+ posts

My First Extension!

nathanprocks wrote:

You should replace some of the ‘if’ statements to ‘switch’ because it make code easier to read and update.
// Use this
switch(pie) {
    case 'pi':
        return Math.PI;
        break;
    case 'e':
        return Math.E;
        break;
    default:
        return;
}
You don't need break after return and you don't need the default case at all.
// Use this
switch(pie) {
    case 'pi': return Math.PI;
    case 'e': return Math.E;
}

nXIII · GitHub
nathanprocks
Scratcher
1000+ posts

My First Extension!

nXIII wrote:

nathanprocks wrote:

You should replace some of the ‘if’ statements to ‘switch’ because it make code easier to read and update.
// Use this
switch(pie) {
    case 'pi':
        return Math.PI;
        break;
    case 'e':
        return Math.E;
        break;
    default:
        return;
}
You don't need break after return and you don't need the default case at all.
// Use this
switch(pie) {
    case 'pi': return Math.PI;
    case 'e': return Math.E;
}
Oh, well I learned something new.


My browser / operating system: Macrosoft Winding XO, Internet Exploder 6.0, Angel Player ver.:1.2.5
;

Powered by DjangoBB