Discuss Scratch

BFDISuperFan
Scratcher
100+ posts

“Delete all orphan blocks and 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 event block, which is what all scripts have to start with. You could also have it so that any event 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 event 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 event 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 <(foo) = [1234]> then
clear
end

when green flag clicked
if <(foo) = [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.

Last edited by BFDISuperFan (Feb. 21, 2019 18:23:19)


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? Here’s the link: https://scratch.mit.edu/projects/120132146/

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 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.

PrincessFlowerTV ✿
but you can call me PFTV for short.
Just your average teen girl who is a Christian, peacemaker, artist, writer, flutist, Forum Helper, Wiki editor, and is homeschooled. Oh yeah, and i'm obsessed with pastels. Okay, maybe i'm not as normal as I think...
(Old)My Blog QAS Question Dictionary Rejected Suggestions
Posting since 2016 - 2,000+ posts




Za-Chary
Scratch Team
1000+ posts

“Delete all orphan blocks and 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)


Za-Chary's Game Museum
The Complete List of Rejected Suggestions
“Things I'm Reading and Playing” Posting Guidelines

“Okay, that's all the time I've got. I gotta get back to playing ‘Animal Crossing: New Leaf’ on my Nintendo 3DS.”
– Reggie Fils-Aimé
BFDISuperFan
Scratcher
100+ posts

“Delete all orphan blocks and 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? Here’s the link: https://scratch.mit.edu/projects/120132146/

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 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)

Mr_PenguinAlex
Scratcher
1000+ posts

“Delete all orphan blocks and 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.

Click here to join me in Stardew Valley!

If you read this on at least 3 different topics or threads, I'm invading the forums.
Za-Chary
Scratch Team
1000+ posts

“Delete all orphan blocks and 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.

Za-Chary's Game Museum
The Complete List of Rejected Suggestions
“Things I'm Reading and Playing” Posting Guidelines

“Okay, that's all the time I've got. I gotta get back to playing ‘Animal Crossing: New Leaf’ on my Nintendo 3DS.”
– Reggie Fils-Aimé
Robby_Blue
Scratcher
100+ posts

“Delete all orphan blocks and 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 Youtube channel

I make weekly Scratch Tutorials
-Rex-
Scratcher
100+ posts

“Delete all orphan blocks and 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 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? Here’s the link: https://scratch.mit.edu/projects/120132146/

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 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 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? ^^

BFDISuperFan
Scratcher
100+ posts

“Delete all orphan blocks and 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? Here’s the link: https://scratch.mit.edu/projects/120132146/

What? An evil kumquat? Eating signatures!? Haha, you come up with some funny things-
Hey, where did my closing signature go?
-Rex-
Scratcher
100+ posts

“Delete all orphan blocks and 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
33 posts

“Delete all orphan blocks and 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 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? Here’s the link: https://scratch.mit.edu/projects/120132146/

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 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 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? Here’s the link: https://scratch.mit.edu/projects/120132146/

What? An evil kumquat? Eating signatures!? Haha, you come up with some funny things-
Hey, where did my closing signature go?

Powered by DjangoBB

Standard | Mobile