Discuss Scratch

BFDISuperFan
Scratcher
100+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

When you right-click at a blank spot in the editor, you have some options like “clean up” which sort all the scripts and blocks in your code so that they don’t overlap each other. However it seems a little bit lacking since rather than “cleaning” you’re kind of just organizing everything. A secondary “clean up” option would sort the scripts, and delete all blocks that aren’t connected to an hat block, which is what all scripts have to start with. You could also have it so that any hat blocks that have no script under them are also deleted, and even select a specific type of blocks that should be deleted, like a drop down menu where you can select operators, events, variables, etc.

Organized, uncluttered code is something we all want, but just like some of our rooms, we just need a bit more help with clean up rather than just organizing the trash with the important stuff.

Of course, this could end up deleting some scripts that were temporarily removed from hat blocks for testing, so adding a warning to confirm your option is probably a good idea.

Example with Scratch blocks:
when [y v] key pressed
clear
^ This script is connected so it won’t get deleted.

if <key [y v] pressed?> then
clear
end

when green flag clicked
^ Since the if then block isn’t connected to a hat block, it gets deleted. The event block also gets deleted because there is no script under it.

Another option in conjunction to this is removing all duplicate scripts, if there are multiples of the exact same script (structure of blocks and values of text inputs are all the same), all but one of them get deleted.
Example:
when green flag clicked
clear

when green flag clicked
clear
^ Since a duplicate script was found, all but one of them get deleted.

when green flag clicked
if <(oof) = [1234]> then
clear
end

when green flag clicked
if <(oof) = [4321]> then
clear
end
^ While the block structure is the same, these scripts aren’t a duplicate because the text input aren’t the same, so they won’t get deleted.

The duplicate script deleter ONLY looks for connected scripts, since the orphan blocks or unconnected scripts will get deleted by the first deleter anyways.
These two deleters could either be in the same option or separate options or both.

Current Supporters (26):
@PrincessFlowerTV
@Za-Chary
@-ShadowOfTheFuture-
@Robby_Blue
@-Rex-
@TheRealNetherBefore
@NilsTheBest
@chrdagos
@EIephant_Lover (Partial Support)
@Nambaseking01
@mica43683
@Kcommand
@hotpig (This user accidentally made a duplicate topic of this, so I think it's safe to assume that they support this.)
@AlexeyChub
@GuineaGod
@PizzaAddict4Life
@TeamPopac
@MapleSyrup911
@mitdk
@jae0921 (This user accidentally made a duplicate topic of this, so I think it's safe to assume that they support this.)
@-CloudGate- (This user supported jae0921's suggestion.)
@hurricane459
@MartianSoil
@gosoccerboy5 (Does not support “Delete duplicate scripts” due to it having certain exceptions. More details shown in their post.)
@Vadik1 (Wanted to suggest a few changes, their post can be found here.)
@sportfan999

Last edited by BFDISuperFan (Nov. 14, 2020 23:52:45)


Oh hi signature reader! Thanks for reading this post. I’m BFDISuperFan, and I really love rhythm games. Oh, and while you’re here reading this, if you also like rhythm games, how about you go try out my attempt at porting DDRMAX2 on Scratch?
I'm also attempting to recreate beatmania IIDX 15: DJ TROOPERS on Scratch, but right now it's just a glorified animation gallery, check it out if you're interested!
What? An evil kumquat? Eating signatures!? Haha, you come up with some funny things-
Hey, where did my closing signature go?
PrincessFlowerTV
Scratcher
1000+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Interesting idea. Support! This would be convenient for keeping the editor clean, and just a nice feature in general.

Got to be good looking cause he's so hard to see -The Beatles

(Thank you @just-there from The Profile Picture Shop for the banner ^^)





Nothing's down here, sorry to disappoint you.






JK. there may be something down there…









Maybe not, tho.











You're determined, aren't you?













Talar du Svenska? Om inte, det ar fin.





















Just stop it, will ya?

































Fine, you win.




Take a rice cake. *yeets you a rice cake*
Say “Thanks for that rice cake, Kewpie!” if you made it this far.
Za-Chary
Scratcher
1000+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Support.

This would help keep the interface nice and clean, perhaps not quite as cluttered with scripts that we are no longer using. However, there should probably be a dialogue box with this along the lines of “Are you sure you want to do this?” After all, we're potentially deleting mass amounts of scripts, and could potentially click it by mistake.

EDIT: See @NilsTheBest's post below — I think he's right. I would support if this were the case for HAT blocks, not EVENT blocks.

Last edited by Za-Chary (Feb. 24, 2019 17:47:44)


This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.

I was a Scratch Team member from May 10th 2019 to October 29th 2021.

my notebook | scratch team essay | accessibility essay
BFDISuperFan
Scratcher
100+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Za-Chary wrote:

Support.

This would help keep the interface nice and clean, perhaps not quite as cluttered with scripts that we are no longer using. However, there should probably be a dialogue box with this along the lines of “Are you sure you want to do this?” After all, we're potentially deleting mass amounts of scripts, and could potentially click it by mistake.
Don't worry, I already have the warning part covered.

Oh hi signature reader! Thanks for reading this post. I’m BFDISuperFan, and I really love rhythm games. Oh, and while you’re here reading this, if you also like rhythm games, how about you go try out my attempt at porting DDRMAX2 on Scratch?
I'm also attempting to recreate beatmania IIDX 15: DJ TROOPERS on Scratch, but right now it's just a glorified animation gallery, check it out if you're interested!
What? An evil kumquat? Eating signatures!? Haha, you come up with some funny things-
Hey, where did my closing signature go?
-ShadowOfTheFuture-
Scratcher
1000+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Support!

This would really help me (and many other people, I'd imagine) with cleaning up my scripts.

Last edited by -ShadowOfTheFuture- (Feb. 22, 2019 00:25:55)


<Insert uncreative signature here>









██       ██  ██            ██  ██       ██
██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██
███ ███ ██ ████ ██ ███ ███
█████████ █████ █████ █████████

“Though the seasons come and go, and sunshine turns to snow, we will always have tomorrow up ahead.”
Mr_PenguinAlex
Scratcher
1000+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Okay, deleting the scripts not connected to an event block?
That sounds dumb!
Deleting the events block not connected to scripts?
That also sounds dumb!

I like the rest, though.

Za-Chary
Scratcher
1000+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Mr_PenguinAlex wrote:

Okay, deleting the scripts not connected to an event block?
That sounds dumb!
Deleting the events block not connected to scripts?
That also sounds dumb!

I like the rest, though.
This is a discussion forum. Generally what you're supposed to do is discuss about what this user suggested. Saying that it “sounds dumb” is not really constructive or respectful. Honestly, this particular suggestion is quite useful, as you've seen us supporters mention.

In the future, please explain why you don't support the suggestion, and what could be done to make it better, or else others might think that your comments are maffolubanbito.

This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.

I was a Scratch Team member from May 10th 2019 to October 29th 2021.

my notebook | scratch team essay | accessibility essay
Robby_Blue
Scratcher
100+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

That's a really good Idea and would be really helpful for many of my scripts! I support this!

Check out my project showing user's stats
-Rex-
Scratcher
500+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Support, but only if the duplicate script detector skips over scripts containing a “change” block, such as
when gf clicked
change [var v] by (1)
change volume by (10) %
BFDISuperFan
Scratcher
100+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

-Rex- wrote:

Support, but only if the duplicate script detector skips over scripts containing a “change” block, such as
when gf clicked
change [var v] by (1)
change volume by (10) %
Sounds like a good plan. The duplicate script detector should usually only look for scripts that don't do anything different whether or not there was only one of the script in the first place.

when green flag clicked
hide

when green flag clicked
hide
^ The hide script doesn't do anything different when there is a duplicate.

when green flag clicked
change volume by (10)

when green flag clicked
change volume by (10)
^ In this case, having the same script twice doubles the volume change to 20, instead of 10.

So to reiterate:
Blocks that set a property or value don't do anything different when there are duplicates.
However, blocks that change the value can be multiplied in their effects depending on how many duplicates there are.

Last edited by BFDISuperFan (Feb. 24, 2019 07:23:00)


Oh hi signature reader! Thanks for reading this post. I’m BFDISuperFan, and I really love rhythm games. Oh, and while you’re here reading this, if you also like rhythm games, how about you go try out my attempt at porting DDRMAX2 on Scratch?
I'm also attempting to recreate beatmania IIDX 15: DJ TROOPERS on Scratch, but right now it's just a glorified animation gallery, check it out if you're interested!
What? An evil kumquat? Eating signatures!? Haha, you come up with some funny things-
Hey, where did my closing signature go?
TheRealNetherBefore
Scratcher
1000+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Support, this seems like a pretty decent feature that could be useful in big projects, though my only concern is that the ‘button’ title is a bit long and potentially confusing for new coders who might not know what “orphan blocks” means.

*Drinks ketchup*
there is no ethical consumption under capitalism my dudes
Small Games | Tips and Advice | Boredom Cat | Misc
Want to make a fantasy world everyone on scratch can use? Click here!
G'thorpax the Unspoken
NilsTheBest
Scratcher
1000+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Good idea, support! In big projects, I often end up with lots of unused scripts everywhere and it gets quite disorganized.

However, by deleting all scripts that aren't connected to event blocks, I think you meant scripts that aren't connected to hat blocks. For example, this script:
broadcast [hi v]
move (13) steps
would not be deleted, because it is connected to an event block.

This:
when I start as a clone
say [hi] for (2) secs
would be deleted, because it isn't connected to an event block.

See what I mean? ^^

NilsTheChair | 5 years on Scratch | 4000+ posts | former wiki editor | 332nd FPC | CoR founder
BFDISuperFan
Scratcher
100+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

NilsTheBest wrote:

Good idea, support! In big projects, I often end up with lots of unused scripts everywhere and it gets quite disorganized.

However, by deleting all scripts that aren't connected to event blocks, I think you meant scripts that aren't connected to hat blocks. For example, this script:
broadcast [hi v]
move (13) steps
would not be deleted, because it is connected to an event block.

This:
when I start as a clone
say [hi] for (2) secs
would be deleted, because it isn't connected to an event block.

See what I mean? ^^
Ah yes, that's what I meant. Thanks for the clarification!

Oh hi signature reader! Thanks for reading this post. I’m BFDISuperFan, and I really love rhythm games. Oh, and while you’re here reading this, if you also like rhythm games, how about you go try out my attempt at porting DDRMAX2 on Scratch?
I'm also attempting to recreate beatmania IIDX 15: DJ TROOPERS on Scratch, but right now it's just a glorified animation gallery, check it out if you're interested!
What? An evil kumquat? Eating signatures!? Haha, you come up with some funny things-
Hey, where did my closing signature go?
-Rex-
Scratcher
500+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

BFDISuperFan wrote:

-Rex- wrote:

Support, but only if the duplicate script detector skips over scripts containing a “change” block, such as
when gf clicked
change [var v] by (1)
change volume by (10) %
Sounds like a good plan. The duplicate script detector should usually only look for scripts that don't do anything different whether or not there was only one of the script in the first place.

when green flag clicked
hide

when green flag clicked
hide
^ The hide script doesn't do anything different when there is a duplicate.

when green flag clicked
change volume by (10)

when green flag clicked
change volume by (10)
^ In this case, having the same script twice doubles the volume change to 20, instead of 10.

So to reiterate:
Blocks that set a property or value don't do anything different when there are duplicates.
However, blocks that change the value can be multiplied in their effects depending on how many duplicates there are.
This can become tricky though, because what if a script calls a custom block or broadcast with a change block in it?
sk7725
Scratcher
35 posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Or maybe for the duplication deleting part, jus make the Clean Up option sort blocks alphabetically. The query for alphabetication should be all of the block's strings joined together(think scratchblocks?). That will make duplicates and similars end up near each other, so you can decide for yourself.

Creator of *Mochi Run* along with some others, and still Scratching on!

KOI is pretty easy, hope IOI is better…
Now solving all your Scratch 3.0 problems! Comment me here!

달려라 나의 모찌! ><
BFDISuperFan
Scratcher
100+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

sk7725 wrote:

Or maybe for the duplication deleting part, jus make the Clean Up option sort blocks alphabetically. The query for alphabetication should be all of the block's strings joined together(think scratchblocks?). That will make duplicates and similars end up near each other, so you can decide for yourself.
Good idea! But right now the clean up option kind of sorts everything in one long vertical line, so maybe it should be better to get that fixed first.

Oh hi signature reader! Thanks for reading this post. I’m BFDISuperFan, and I really love rhythm games. Oh, and while you’re here reading this, if you also like rhythm games, how about you go try out my attempt at porting DDRMAX2 on Scratch?
I'm also attempting to recreate beatmania IIDX 15: DJ TROOPERS on Scratch, but right now it's just a glorified animation gallery, check it out if you're interested!
What? An evil kumquat? Eating signatures!? Haha, you come up with some funny things-
Hey, where did my closing signature go?
Fupicat
Scratcher
1000+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

sk7725 wrote:

Or maybe for the duplication deleting part, jus make the Clean Up option sort blocks alphabetically. The query for alphabetication should be all of the block's strings joined together(think scratchblocks?). That will make duplicates and similars end up near each other, so you can decide for yourself.
No! The clean up option should sort the blocks by the order of how they are placed, so you can organize your work better. The letter they start with is meaningless. What they do is what matters.



BFDISuperFan
Scratcher
100+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Bump

Oh hi signature reader! Thanks for reading this post. I’m BFDISuperFan, and I really love rhythm games. Oh, and while you’re here reading this, if you also like rhythm games, how about you go try out my attempt at porting DDRMAX2 on Scratch?
I'm also attempting to recreate beatmania IIDX 15: DJ TROOPERS on Scratch, but right now it's just a glorified animation gallery, check it out if you're interested!
What? An evil kumquat? Eating signatures!? Haha, you come up with some funny things-
Hey, where did my closing signature go?
chrdagos
Scratcher
500+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Za-Chary wrote:

Support.

This would help keep the interface nice and clean, perhaps not quite as cluttered with scripts that we are no longer using. However, there should probably be a dialogue box with this along the lines of “Are you sure you want to do this?” After all, we're potentially deleting mass amounts of scripts, and could potentially click it by mistake.

EDIT: See @NilsTheBest's post below — I think he's right. I would support if this were the case for HAT blocks, not EVENT blocks.
I agree. I remember that I had a remix of Will_Wam's “Super Mario Bros.” and when I looked inside, it was a mess. I spent a good amount of time going through every sprite and the stage, deleting a bunch of scripts that had no hat block. One of them was no less than 173 blocks. 173 blocks!
So I Support this.
Oh, and this option can also reduce the amount of memory that is taken up, too.
EIephant_Lover
Scratcher
500+ posts

“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface

Mm, like 70% support.

First off, like NilsTheBest said, it should be hat blocks, not event blocks.

But I don't support having both the “delete orphan blocks” and “delete duplicate blocks” lumped together. Like some people have mentioned, deleting duplicate blocks could change the project's code:

BFDISuperFan wrote:

-snip-

when green flag clicked
hide

when green flag clicked
hide
^ The hide script doesn't do anything different when there is a duplicate.

when green flag clicked
change volume by (10)

when green flag clicked
change volume by (10)
^ In this case, having the same script twice doubles the volume change to 20, instead of 10.

Powered by DjangoBB