Discuss Scratch

AliceLouiseBeth
New to Scratch
2 posts

Removing items from lists

Hi,

I'm trying to make a customised Only Connect game board (the quiz show from BBC4). I managed to find one that ‘HenrysCat’ had already made which was a great help because I'm pretty new to Scratch and don't know much about programming! I've customised it to look more like the actual game but I really want to be able to choose an item and then get rid of it again if necessary.

So, once you click on an item it goes into the ‘picked list’. I tried adding script so that if you have your mouse on it and press ‘d’ it gets deleted from the list but it doesn't work because it will only find something in the list by number rather than name and I don't know what order the items will be put into the list by the player so I can't specify what number it will be.

I don't think I explained this very well but the game is here: http://scratch.mit.edu/projects/11657561/

It might make more sense to look at it. The aim of game is to sort the 16 squares into groups of 4 that link together. I'm trying to make it for a friend who loves the show!

Anyway, any help would be appreciated. And in simple language please!
drmcw
Scratcher
1000+ posts

Removing items from lists

You need to loop through the list using a variable. SO something like;

set loop to 1
repeat until loop > length of list
if item loop of list = what I am looking for then
delete loop of list
set loop to length of list + 1
else
change loop by 1

Hopefully that makes sense. loop is s variable and list is a list. “What I am looking for” needs to be the data you are looking to delete from the list. The reason I then set loop to length of list + 1 is because we have deleted the item and so don't need to loop around anymore, doing this will then exit the repeat loop. I haven't tested this but think it should work but can make a project for you if you have problems.

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
AliceLouiseBeth
New to Scratch
2 posts

Removing items from lists

I have no idea what any of that meant - but it worked perfectly! Thanks a lot
drmcw
Scratcher
1000+ posts

Removing items from lists

Great…….erm I think!

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?

Powered by DjangoBB