How do I get a random value that isn't the same?

I will make my 1-10 values disappear.
For example
When I randomly get the number 5, I will do it again.
And 5 will not be reborn What to do
Suppose I have 10 items. I uncovered all the items uniquely. What to do?
Mmm, I can only think of a scripted way which I often use...

First Step!
Initialize the variable to contain only the numbers that would appear into an array. This can be done either manually or scripted. I recommend it to be done manually :
1582118476255.png

You want to initialize it only once! Unless you want to re-initialized the value.

Second Step!
Store the randomized number to another variable :
1582119481633.png

This is the code :
$gameVariables.value(ID).splice(Math.randomInt($gameVariables.value(ID).length),1)
Change ID to the variable ID that contain the array.

Extra Step! (optional)
This is only to avoid error when the content are emptied. Make a conditional branch that check if the array are empty or not.
1582119926145.png

This is the code :
$gameVariables.value(ID).length > 0
and yes, change ID to the variable ID that contain the array.
Then put the executed command (second step) inside of it.

Aaand you are done!
It shoud've looked like this :
1582120027425.png

Var B now contain randomized number inside Var A, and A will lose that number.

I've moved this thread to MV Support. Thank you.


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-get-a-random-value-that-isnt-the-same.118378/