Discuss Scratch
- Discussion Forums
- » Suggestions
- » “Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface
- BFDISuperFan
-
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:
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:
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
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^ This script is connected so it won’t get deleted.
clear
if <key [y v] pressed?> then^ 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.
clear
end
when green flag clicked
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^ Since a duplicate script was found, all but one of them get deleted.
clear
when green flag clicked
clear
when green flag clicked^ 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.
if <(oof) = [1234]> then
clear
end
when green flag clicked
if <(oof) = [4321]> then
clear
end
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)
- PrincessFlowerTV
-
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.
- Za-Chary
-
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.
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)
- BFDISuperFan
-
100+ posts
“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface
Don't worry, I already have the warning part covered. 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.
- -ShadowOfTheFuture-
-
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.
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)
- MrFluffyPenguins
-
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.
That sounds dumb!
Deleting the events block not connected to scripts?
That also sounds dumb!
I like the rest, though.
- Za-Chary
-
1000+ posts
“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface
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. 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.
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.
- Robby_Blue
-
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!
- -Rex-
-
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
-
100+ posts
“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface
but only if the duplicate script detector skips over scripts containing a “change” block, such asSounds 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. Support,when gf clicked
change [var v] by (1)
change volume by (10) %
when green flag clicked^ The hide script doesn't do anything different when there is a duplicate.
hide
when green flag clicked
hide
when green flag clicked^ In this case, having the same script twice doubles the volume change to 20, instead of 10.
change volume by (10)
when green flag clicked
change volume by (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)
- TheRealNetherBefore
-
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.
- NilsTheBest
-
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:
This:
See what I mean? ^^
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]would not be deleted, because it is connected to an event block.
move (13) steps
This:
when I start as a clonewould be deleted, because it isn't connected to an event block.
say [hi] for (2) secs
See what I mean? ^^
- BFDISuperFan
-
100+ posts
“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface
Ah yes, that's what I meant. Thanks for the clarification! 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]would not be deleted, because it is connected to an event block.
move (13) steps
This:when I start as a clonewould be deleted, because it isn't connected to an event block.
say [hi] for (2) secs
See what I mean? ^^
- -Rex-
-
500+ posts
“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface
This can become tricky though, because what if a script calls a custom block or broadcast with a change block in it?but only if the duplicate script detector skips over scripts containing a “change” block, such asSounds 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. Support,when gf clicked
change [var v] by (1)
change volume by (10) %when green flag clicked^ The hide script doesn't do anything different when there is a duplicate.
hide
when green flag clicked
hidewhen green flag clicked^ In this case, having the same script twice doubles the volume change to 20, instead of 10.
change volume by (10)
when green flag clicked
change volume by (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.
- sk7725
-
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.
- BFDISuperFan
-
100+ posts
“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface
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. 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.
- Fupicat
-
1000+ posts
“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface
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. 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.
- BFDISuperFan
-
100+ posts
“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface
Bump
- chrdagos
-
500+ posts
“Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface
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! 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.
So I Support this.
Oh, and this option can also reduce the amount of memory that is taken up, too.
- EIephant_Lover
-
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:
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:
-snip-when green flag clicked^ The hide script doesn't do anything different when there is a duplicate.
hide
when green flag clicked
hidewhen green flag clicked^ In this case, having the same script twice doubles the volume change to 20, instead of 10.
change volume by (10)
when green flag clicked
change volume by (10)
- Discussion Forums
- » Suggestions
-
» “Delete all orphan blocks" and "Delete duplicate scripts” option in right-click interface