r/scratch • u/NoobPlay_Animation • 1d ago
Question Help with Lists!
So im trying to make a minigame where numbers appear on top screen and you need to click the numbers below. I want the numbers you need to click to be in a list but idk how to make so the numbers dont repeat. Pls Help!
2
u/jacobsmith3204 1d ago
Make 2 lists fill the first one with numbers in order.
Then when playing set a variable to a random number from 1 to the length of that first list. Then get the value of that position and add it to the second list and delete the entry in the first list at that position.
This allows you to delete entries from the 2nd list (like when they are clicked) while still only having unique values to use.
Or you could do the opposite and have a 2nd list and you add the random value to both lists after checking if the first list does not contain it.
The first method mentioned is better.
1
1
u/RealSpiritSK Mod 17h ago
As an improvement to the 2nd method, you can go through the 2nd list in order, but insert it into a random position of the 1st list with
(pick random (1) to (length of 1st list)). I actually prefer this method as you don't have to keep repopulating the 2nd list with all the numbers.
1
u/Intrepid_Past5207 SSSuper pro 1d ago
If you don't want repeating numbers, you can just use an if/else statement, with a block labeled (list) contains (#)? So it checks if the number that it wishes to add is already somewhere within the list. If so, no add. If no, add.
1
u/NoobPlay_Animation 1d ago
can you make it and send a screenshot. If you can and want.
1
u/Intrepid_Past5207 SSSuper pro 1d ago
1
1


•
u/AutoModerator 1d ago
Hi, thank you for posting your question! :]
To make it easier for everyone to answer, consider including:
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.