Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to remove SPECIFIC thing from list?
- FerretBandit
-
Scratcher
38 posts
How to remove SPECIFIC thing from list?
Hi,
I'm working on a game but I can't seem to find how to remove a specific item from a list.
The only way I can remove something is buy deleting a specific numbered item, but how do I remove a specific named item that could be at any number on the list? The “delete _ from list” script only allows me to type in the number of the thing I want to remove. For example, if I want the player to remove “Zombie” from the list, and the “Zombie” item could be at any number on the list, how could I make it remove the “Zombie” item at whatever number it is currently at?
If you want to see what I mean, here is the game: https://scratch.mit.edu/projects/139984123/
The sprite I'm trying to remove specific list items from is the last sprite (Sprite79)
I'm working on a game but I can't seem to find how to remove a specific item from a list.
The only way I can remove something is buy deleting a specific numbered item, but how do I remove a specific named item that could be at any number on the list? The “delete _ from list” script only allows me to type in the number of the thing I want to remove. For example, if I want the player to remove “Zombie” from the list, and the “Zombie” item could be at any number on the list, how could I make it remove the “Zombie” item at whatever number it is currently at?
If you want to see what I mean, here is the game: https://scratch.mit.edu/projects/139984123/
The sprite I'm trying to remove specific list items from is the last sprite (Sprite79)
- drmcw
-
Scratcher
1000+ posts
How to remove SPECIFIC thing from list?
Use a loop and go through the list incrementing a variable by one each time. Use that as the index to “find” the correct item in the list which you can then delete as you then know it's index number.
- FerretBandit
-
Scratcher
38 posts
How to remove SPECIFIC thing from list?
Use a loop and go through the list incrementing a variable by one each time. Use that as the index to “find” the correct item in the list which you can then delete as you then know it's index number.Sorry, I don't understand. Can you tell me the blocks I should use?
- Th3_C0d3r
-
Scratcher
100+ posts
How to remove SPECIFIC thing from list?
Here is a simple script…
(Make sure to run the block without screen refresh for faster results)
You can know simply use like this
Example:
-Scratch On!
(Make sure to run the block without screen refresh for faster results)
define Remove (Item) From List
if <[List v] contains (Item) ?> then
set [I v] to [1]//This is your counter variable
repeat (length of [List v] :: list)
if <(item (I) of [list v] :: list) = (Item)> then//If your item is found -delete
delete ( I) of [list v]
end
change [I v] by (1)//keep searching for more
end
end
You can know simply use like this
Example:
when green flag clicked
Remove [Zombie] From List//Ignore the red it's suppose to be purple
-Scratch On!
- asivi
-
Scratcher
1000+ posts
How to remove SPECIFIC thing from list?
This will delete all items in a list containing “zombie”:
define delete word (word)
if <[list v] contains (word) ?> then
set [item # v] to [0]
repeat (length of [list v] :: list)
change [item # v] by (1)
if <(item (item #) of [list v] :: list) = (word)> then
delete (item #) of [list v]
end
end
end
delete word [zombie] :: custom
- asivi
-
Scratcher
1000+ posts
How to remove SPECIFIC thing from list?
OhMyLol.
Sorry for the duplicate.
Sorry for the duplicate.
- FerretBandit
-
Scratcher
38 posts
How to remove SPECIFIC thing from list?
Here is a simple script…How do I get the “Item” block to put in the "if list contains (Item) ?
(Make sure to run the block without screen refresh for faster results)define Remove (Item) From List
if <[List v] contains (Item) ?> then
set [I v] to [1]//This is your counter variable
repeat (length of [List v] :: list)
if <(item (I) of [list v] :: list) = (Item)> then//If your item is found -delete
delete ( I) of [list v]
end
change [I v] by (1)//keep searching for more
end
end
You can know simply use like this
Example:when green flag clicked
Remove [Zombie] From List//Ignore the red it's suppose to be purple
-Scratch On!
- Th3_C0d3r
-
Scratcher
100+ posts
How to remove SPECIFIC thing from list?
How do I get the “Item” block to put in the "if list contains (Item) ?
When you create/edit a custom block, the option will come up. Click Options. Then Click, Add String input (The grey square block) and then click okay. Note: You can edit the names in the preview above.
-Scratch On!
- FerretBandit
-
Scratcher
38 posts
How to remove SPECIFIC thing from list?
That's not what I mean, I'm asking how to get the (Item) block by itself.How do I get the “Item” block to put in the "if list contains (Item) ?
When you create/edit a custom block, the option will come up. Click Options. Then Click, Add String input (The grey square block) and then click okay. Note: You can edit the names in the preview above.
-Scratch On!
<[List v] contains [] ?>How do I get the (item) block to insert here? ^^^
- Th3_C0d3r
-
Scratcher
100+ posts
How to remove SPECIFIC thing from list?
That's not what I mean, I'm asking how to get the (Item) block by itself.Do the steps I said before. And once you create the custom block correctly. You can click & drag the, “Item” block from the purple Define hat block into the<[List v] contains [] ?>How do I get the (item) block to insert here? ^^^
<[List v] contains (Item) ?>It'll be similar to a variable block
-Scratch On!
- FerretBandit
-
Scratcher
38 posts
How to remove SPECIFIC thing from list?
That works, thanks!That's not what I mean, I'm asking how to get the (Item) block by itself.Do the steps I said before. And once you create the custom block correctly. You can click & drag the, “Item” block from the purple Define hat block into the<[List v] contains [] ?>How do I get the (item) block to insert here? ^^^<[List v] contains (Item) ?>It'll be similar to a variable block
-Scratch On!
- drmcw
-
Scratcher
1000+ posts
How to remove SPECIFIC thing from list?
(Make sure to run the block without screen refresh for faster results)
Corrected
define Remove (Item) From List
if <[List v] contains (Item) ?> then
set [I v] to [1]//This is your counter variable
repeat (length of [List v] :: list)
if <(item (I) of [list v] :: list) = (Item)> then//If your item is found -delete
delete ( I) of [list v]
stop [this script v] // you really should add this.
end
change [I v] by (1)//keep searching for more
end
end
Corrected

Last edited by drmcw (Jan. 28, 2017 21:13:48)
- DirefulDread75
-
Scratcher
1 post
How to remove SPECIFIC thing from list?
Here is a simple script…
(Make sure to run the block without screen refresh for faster results)define Remove (Item) From List
if <[List v] contains (Item) ?> then
set [I v] to [1]//This is your counter variable
repeat (length of [List v] :: list)
if <(item (I) of [list v] :: list) = (Item)> then//If your item is found -delete
delete ( I) of [list v]
end
change [I v] by (1)//keep searching for more
end
end
You can know simply use like this
Example:when green flag clicked
Remove [Zombie] From List//Ignore the red it's suppose to be purple
-Scratch On!
- deck26
-
Scratcher
1000+ posts
How to remove SPECIFIC thing from list?
Please check what you post actually works - if you think you can delete an item from a list just by giving the actual item contents you're wrong.Here is a simple script…
(Make sure to run the block without screen refresh for faster results)define Remove (Item) From List
if <[List v] contains (Item) ?> then
set [I v] to [1]//This is your counter variable
repeat (length of [List v] :: list)
if <(item (I) of [list v] :: list) = (Item)> then//If your item is found -delete
delete ( I) of [list v]
end
change [I v] by (1)//keep searching for more
end
end
You can know simply use like this
Example:when green flag clicked
Remove [Zombie] From List//Ignore the red it's suppose to be purple
-Scratch On!
- FerretBandit
-
Scratcher
38 posts
How to remove SPECIFIC thing from list?
It works. Necropost though.Please check what you post actually works - if you think you can delete an item from a list just by giving the actual item contents you're wrong.Here is a simple script…
(Make sure to run the block without screen refresh for faster results)define Remove (Item) From List
if <[List v] contains (Item) ?> then
set [I v] to [1]//This is your counter variable
repeat (length of [List v] :: list)
if <(item (I) of [list v] :: list) = (Item)> then//If your item is found -delete
delete ( I) of [list v]
end
change [I v] by (1)//keep searching for more
end
end
You can know simply use like this
Example:when green flag clicked
Remove [Zombie] From List//Ignore the red it's suppose to be purple
-Scratch On!

- Brian3141
-
Scratcher
25 posts
How to remove SPECIFIC thing from list?
Sorry for necroposting but let's say there is a leader board and some people like to troll by adding multiple of their own names. How do I delete the lowest score they had but let them keep their highest score??? I DONT KNOW HOW TO DO THIS
- a-jar-of-tuna
-
Scratcher
100+ posts
How to remove SPECIFIC thing from list?
It's usually more helpful to you and other scratchers if you just start your own topic when you have a question, instead of necroposting.
Last edited by a-jar-of-tuna (July 18, 2019 09:03:39)
- Brian3141
-
Scratcher
25 posts
How to remove SPECIFIC thing from list?
It's usually more helpful to you and other scratchers if you just start your own topic when you have a question, instead of necroposting.
I don't know how to
- PinkTabbyHunterLargo
-
Scratcher
100+ posts
How to remove SPECIFIC thing from list?
go to help with scripts, but don't click on the topics. instead, look at the top bar that says “Help with Scripts”, then look at the other end of the bar. click on the blue button that says ‘New Topic’. put in something for the topic to be called and then your post that you want an answer for. now do you understand how to make a new topic?It's usually more helpful to you and other scratchers if you just start your own topic when you have a question, instead of necroposting.
I don't know how to
- Discussion Forums
- » Help with Scripts
-
» How to remove SPECIFIC thing from list?
