Discuss Scratch

KittyFireSt0rm
Scratcher
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
delete all occurrences of (  ) ::list
block, and a

 
delete all occurences of ( ) in [list v] ::list
block

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
Scratcher
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
Scratcher
1000+ posts

"Delete all occurrences of" block

scratchastroLOL wrote:

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

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
KittyFireSt0rm
Scratcher
1000+ posts

"Delete all occurrences of" block

Bump (Second Page)
BosenChang
Scratcher
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
Scratcher
1000+ posts

"Delete all occurrences of" block

BosenChang wrote:

-snip-

Again, I am aware of a workaround, for the
 delete all occurrences of ( ) in [list v] ::list 
block.

The other block
 delete all occurences of ( ) ::list 
is more of a hassle to workaround.
KittyFireSt0rm
Scratcher
1000+ posts

"Delete all occurrences of" block

Bump
KittyFireSt0rm
Scratcher
1000+ posts

"Delete all occurrences of" block

Bump
KittyFireSt0rm
Scratcher
1000+ posts

"Delete all occurrences of" block

Bump again
RoboticAuthor2
Scratcher
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
Scratcher
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
Scratcher
1000+ posts

"Delete all occurrences of" block

fdreerf wrote:

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
Scratcher
1000+ posts

"Delete all occurrences of" block

Bump (24+ hours since last bump)
Vibrato
Scratcher
1000+ posts

"Delete all occurrences of" block

BosenChang wrote:

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
Little correction:
define delete all [] of list
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
Otherwise you'll get out of sync.
scratchastroLOL
Scratcher
1000+ posts

"Delete all occurrences of" block

BosenChang wrote:

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
I don't think this workaround works. You're not allowed to put blocks in square dropdowns.
geometric_ghast
Scratcher
1000+ posts

"Delete all occurrences of" block

Support. I have needed this before, and the workaround is kinda annoying to do.
Vibrato
Scratcher
1000+ posts

"Delete all occurrences of" block

scratchastroLOL wrote:

BosenChang wrote:

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
I don't think this workaround works. You're not allowed to put blocks in square dropdowns.
Huh? Where is the square dropdown?
scratchastroLOL
Scratcher
1000+ posts

"Delete all occurrences of" block

Vibrato wrote:

scratchastroLOL wrote:

BosenChang wrote:

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
I don't think this workaround works. You're not allowed to put blocks in square dropdowns.
Huh? Where is the square dropdown?
<[ v] contains [thing] ?>
That block has a square dropdown, so blocks can't be put inside of this. the workaround doesn't work.
BosenChang
Scratcher
1000+ posts

"Delete all occurrences of" block

scratchastroLOL wrote:

Vibrato wrote:

scratchastroLOL wrote:

BosenChang wrote:

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
I don't think this workaround works. You're not allowed to put blocks in square dropdowns.
Huh? Where is the square dropdown?
<[ v] contains [thing] ?>
That block has a square dropdown, so blocks can't be put inside of this. the workaround doesn't work.
I don't know why, but I think it is a glitch.
The workaround:
define delete all instances of (something)
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
Oh dang heck! I know why! In Scratch 2.0, there was no operators
<[] contains []::operators>
//nor
glide () secs to [mouse-pointer v]::motion
KittyFireSt0rm
Scratcher
1000+ posts

"Delete all occurrences of" block

BosenChang wrote:

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

Powered by DjangoBB