Discuss Scratch
- KittyFireSt0rm
-
1000+ posts
"Delete all occurrences of" block
So, I'm making a game, and the game is currently programmed to delete/kill a cat every 50-300 seconds. (Don't worry, the only purpose of “death” in the game is to keep the population of your group reasonable and the “death” of any given cat is not descriptive, it just says that they die)
The thing is, once they die? I have to get rid of all instances of their name in the six-seven lists where they are or possibly could be.
What am I suggesting?
A
I am aware that there is a workaround (I'm using it right now), but having this block implemented would be a great help! Any ideas on how to improve this suggestion? Please tell me!
also if someone could tell me how to make the blocks list colored that would help too
The thing is, once they die? I have to get rid of all instances of their name in the six-seven lists where they are or possibly could be.
What am I suggesting?
A
delete all occurrences of ( ) ::listblock, and a
block
delete all occurences of ( ) in [list v] ::list
I am aware that there is a workaround (I'm using it right now), but having this block implemented would be a great help! Any ideas on how to improve this suggestion? Please tell me!
also if someone could tell me how to make the blocks list colored that would help too
Last edited by KittyFireSt0rm (July 31, 2020 00:08:54)
- scratchastroLOL
-
1000+ posts
"Delete all occurrences of" block
delete all occurrences of [] :: list
define delete all occurrences of (thing)
repeat until <not <[list v] contains (thing) ?>>
delete (item # of (thing) in [list v] :: list) of [list v]
end
- KittyFireSt0rm
-
1000+ posts
"Delete all occurrences of" block
delete all occurrences of [] :: listdefine delete all occurrences of (thing)
repeat until <not <[list v] contains (thing) ?>>
delete (item # of (thing) in [list v] :: list) of [list v]
end
1) Thank you for that
2) I am aware that there is a workaround, but I have multiple lists I need to delete an item from at once and running this script for every single item I need removed seems a bit of a hassle
- BosenChang
-
1000+ posts
"Delete all occurrences of" block
Yes, I support. But a quick and easy workaround is:
define delete all [] of list
set [i v] to [0]
repeat (length of [list v])
change [i v] by (1)
if <(item (i) of [list v]) contains (::custom)> then
delete (i) of [list v]
end
end
- KittyFireSt0rm
-
1000+ posts
"Delete all occurrences of" block
-snip-
Again, I am aware of a workaround, for the
delete all occurrences of ( ) in [list v] ::listblock.
The other block
delete all occurences of ( ) ::listis more of a hassle to workaround.
- RoboticAuthor2
-
100+ posts
"Delete all occurrences of" block
Support. Although I don't need this block, I could see how it would be very useful! And YES, WE UNDERSTAND THERE IS A WORKAROUND PEOPLE. READ THE OP'S MESSAGE FULLY. There are workarounds to the majority of blocks in Scratch, but why were they added? Because it was easier than a complicated code, and kids would have an easier time.
- fdreerf
-
1000+ posts
"Delete all occurrences of" block
I think it would be better to have “all lists” in the dropdowns for lists blocks for more general purposes.
- KittyFireSt0rm
-
1000+ posts
"Delete all occurrences of" block
I think it would be better to have “all lists” in the dropdowns for lists blocks for more general purposes.
That would also be a good option to have, but not what I'm suggesting

- KittyFireSt0rm
-
1000+ posts
"Delete all occurrences of" block
Bump
(24+ hours since last bump)

- Vibrato
-
1000+ posts
"Delete all occurrences of" block
Little correction: Yes, I support. But a quick and easy workaround is:define delete all [] of list
set [i v] to [0]
repeat (length of [list v])
change [i v] by (1)
if <(item (i) of [list v]) contains (::custom)> then
delete (i) of [list v]
end
end
define delete all [] of listOtherwise you'll get out of sync.
set [i v] to (length of [list v] :: list)
repeat until <[0] = (i)>
if <(item (i) of [list v]) contains (::custom)> then
delete (i) of [list v]
end
change [i v] by (-1)
end
- scratchastroLOL
-
1000+ posts
"Delete all occurrences of" block
I don't think this workaround works. You're not allowed to put blocks in square dropdowns. Yes, I support. But a quick and easy workaround is:define delete all [] of list
set [i v] to [0]
repeat (length of [list v])
change [i v] by (1)
if <(item (i) of [list v]) contains (::custom)> then
delete (i) of [list v]
end
end
- geometric_ghast
-
1000+ posts
"Delete all occurrences of" block
Support. I have needed this before, and the workaround is kinda annoying to do.
- Vibrato
-
1000+ posts
"Delete all occurrences of" block
Huh? Where is the square dropdown?I don't think this workaround works. You're not allowed to put blocks in square dropdowns. Yes, I support. But a quick and easy workaround is:define delete all [] of list
set [i v] to [0]
repeat (length of [list v])
change [i v] by (1)
if <(item (i) of [list v]) contains (::custom)> then
delete (i) of [list v]
end
end
- scratchastroLOL
-
1000+ posts
"Delete all occurrences of" block
Huh? Where is the square dropdown?I don't think this workaround works. You're not allowed to put blocks in square dropdowns. Yes, I support. But a quick and easy workaround is:define delete all [] of list
set [i v] to [0]
repeat (length of [list v])
change [i v] by (1)
if <(item (i) of [list v]) contains (::custom)> then
delete (i) of [list v]
end
end
<[ v] contains [thing] ?>That block has a square dropdown, so blocks can't be put inside of this. the workaround doesn't work.
- BosenChang
-
1000+ posts
"Delete all occurrences of" block
I don't know why, but I think it is a glitch.Huh? Where is the square dropdown?I don't think this workaround works. You're not allowed to put blocks in square dropdowns. Yes, I support. But a quick and easy workaround is:define delete all [] of list
set [i v] to [0]
repeat (length of [list v])
change [i v] by (1)
if <(item (i) of [list v]) contains (::custom)> then
delete (i) of [list v]
end
end<[ v] contains [thing] ?>That block has a square dropdown, so blocks can't be put inside of this. the workaround doesn't work.
The workaround:
define delete all instances of (something)Oh dang heck! I know why! In Scratch 2.0, there was no operators
set [i v] to [0]
repeat (length of [list v])
change [i v] by (1)
if <(i) contains (something::custom)::operators> then
delete (something::custom) of [list v]
end
<[] contains []::operators>
//nor
glide () secs to [mouse-pointer v]::motion
- KittyFireSt0rm
-
1000+ posts
"Delete all occurrences of" block
-snip-
Yes, I get that there is a functional workaround for the
delete all occurrences of ( ) in [list v] :: list
But what about deleting all occurrences across multiple lists?