In my game, I want the level order to randomize, but I don’t want the same level to appear twice. I tried using a list, but there is no “get and remove random value from list” block.
Is there a way to get a random value and then remove it?
In my game, I want the level order to randomize, but I don’t want the same level to appear twice. I tried using a list, but there is no “get and remove random value from list” block.
( ( Level List ) get and remove value at ( pick random ( 0 ) to ( length of array ( ( Level List ) [ - ] ( 1 ) )
You just have to do the random part yourself!
Would this work?
The ‘get and remove value at 0’ seems to be using an index to decide which element to to get and remove. So if you set the index as a random number between 0 and the length of the list, it seems like that get a random index within the range of indices.
@DRay yes but you need to subtract 1 from the length of the array (e.g. “pick random 0 to length of array list - 1”)
Ah, good catch. The 0 indexing means that the length of the list will be 1 more than your index range because the indices start with 0 instead of 1.
Thank you all. You were all a big help!