Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » My First Extension!
- 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!
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. You should probably make “Alert” lowercase to match every other Scratch blocks that ever existed (Except Scratch days). And
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)
- 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!
Meh. I'm just playing with stuff. If I try to submit it, I won't include those blocks. This is pretty dangerous… You can forever open a new tab… and then things go down the tubes
- Braeden5454
- Scratcher
500+ posts
My First Extension!
Didn't you do that on another block?here. Can I add your extension to it?Sure! I made this extension place thingYes. I can't figure out how to remove the checkbox. 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
- PullJosh
- Scratcher
1000+ posts
My First Extension!
It automatically adds it to some blocks but not others. I don't know what they are, so I can't stop meeting them. xDDidn't you do that on another block?here. Can I add your extension to it?Sure! I made this extension place thingYes. I can't figure out how to remove the checkbox. the factorial appears as %n factorial on the screen.
- nathanprocks
- Scratcher
1000+ posts
My First Extension!
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.It automatically adds it to some blocks but not others. I don't know what they are, so I can't stop meeting them. xDDidn't you do that on another block?here. Can I add your extension to it?Sure! I made this extension place thingYes. I can't figure out how to remove the checkbox. the factorial appears as %n factorial on the screen.
- 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)
- PullJosh
- Scratcher
1000+ posts
My First Extension!
Okay, thanks! I didn't know about that. You should replace some of the ‘if’ statements to ‘switch’ because it make code easier to read and update.
(Well, actually, I vaguely remember seeing it a few years ago, but…)
- nXIII
- Scratcher
1000+ posts
My First Extension!
You don't need break after return and you don't need the default case at all. 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; }
// Use this switch(pie) { case 'pi': return Math.PI; case 'e': return Math.E; }
- nathanprocks
- Scratcher
1000+ posts
My First Extension!
Oh, well I learned something new.You don't need break after return and you don't need the default case at all. 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; }// Use this switch(pie) { case 'pi': return Math.PI; case 'e': return Math.E; }
- Discussion Forums
- » Advanced Topics
- » My First Extension!