Download

Array items not deleting?

This code is supposed to pick 1 item from the array (Full Word List) and display it. the user then chooses whether the word is masculine or feminine, and then the word is removed from the array. Everything works correctly except that once per run it displays the same word twice. It is always a random word at a random time, and it usually only happens once per run. How can this be fixed?

Is the maximum correct? Should it be -1 or 0? Remember, arrays are zero-based, so the number of items is actually one more than the index number of the last item.

Instead of using a Maximum value, use the My Array > Last Index nodes. That will give you the maximum number of the array, and as a bonus, as you are checking it on each loop, you don’t have to reduce the Maximum value with every decrement.

could just be a timing issue, try setting the variables before playing animations, that should eliminate the possibility of clicking options a split second before variables are set.

It sounds more like a confusion between length and index.

If you have an array with a length of 3, and choose the third item, then take out item number 3, that is actually the fourth item (which doesn’t exist, so check your logs for an out of bounds error), which explains why you get a duplicate, because the one you picked is still in the array. You still try three times, because that is the length, but you are looking for items [1], [2], [3], not [0], [1], [2].