Exclude some numbers from random number variable

Let's say for example that I assign to a variable a random number from 1 to 10.
I'd like the chosen number to being removed from the count next time I assign a random number to that variable. (I'll accept any method do to this, even multiple event pages).

Example:
Variable = random 1-10 => Variable = 3

3 is removed from the count, so next time i assign a random number, "3" will never be chosen.
the only realistic way to do this is by using an array with elements, and that cannot be done by pure event commands.

basically you start by creating an array of ten elements, give each element one of the numbers from 1 to 10. then you get a random index number, remove the element of that index and use the number inside that element as the value.

Ruby/RGSS3 has functions for array elements, but I don't knoe their syntax, you'll have to search that for yourself.
There's not a way to event this directly, but there are ways to event around this.

Try sticking it in a loop and using switches to mark which numbers have already come up -- if the random number happens to be one that's been used (switched on), then it can just repeat the loop until it gets to one that isn't. If that doesn't make sense, I'm sorry and can post an example.
@BenSD that is a rather bad methology because it creates a lot of lag, especially with the last few numbers.

just imagine: you have already randomly rolled 19 of 20 numbers, and now have to loop around until the random function actually hits the last of the twenty numbers.
your method only works with a low number of elements and becomes extremely bad the more element are in the process.
That's a good point Andar, I was thinking of doing random them save number picked into a second variable and check if it was picked but removing the numbers to pick from like was asked makes more sense. This is my thought so far, but I need to test it. Works
This could be done with script commands in the event.
Set a variable to the numbers you want
$game_variables[xx] = [1,2,3,4,5,6,7,8,9,10]
get random number
$game_variables[xx1] = rand[$game_variables[xx].size)
get number from array
$game_variables[xx2] = $game_variables[xx][$game_variables[xx1]]
remove number from array
$game_variables[xx].delete_at($game_variables[xx1])
1652355406818.png
Code:
ary = [1,3,6,4]
loop
var = rand(10) + 1
while ary.includes?(var)

ish?
I'm a bit rusty in plain code.
So, I just opened up my VX Ace, and I did what BenSD suggested using Andar's numbers (1-20) while I had stuff moving in the background (to detect any lag).

Now, I didn't use loop because I think loop is bad. I used Label and Jump to Label because that seems to work when Loop doesn't. From testing it, the only lag that pops up is when you have all numbers excluded so the game just freezes as its stuck at getting a random number... forever. Even if all but the number 20 is excluded, you should see no lag. The Makers are pretty quick at proccessing. I did Label Redo at the top, the random number right below, and then I checked for each number the variable could've been and to make it easy, I made the Switch ID the same so if it hits 6, Switch will turn on. If said switch is already on, it'll just to Label Redo which is at the top, so it'll never finish until it hits a number it hasn't already hit.

unknown.png
I really thank you all so much for helping!!
I used @Roninator2 's method and it perfectly works.

1652357861453.png

I created the array outside of the event because I thought it would reset with the interaction.


Again, a big thank to you all : D
I created the array outside of the event because I thought it would reset with the interaction.
The way I showed it, it would. Glad you figured that out.
Happy you used my method. Doesn't happen often that I have a simpler or better way than others.
Maybe I'm getting better/smarter.
Happy game making
The way I showed it, it would. Glad you figured that out.
Happy you used my method. Doesn't happen often that I have a simpler or better way than others.
Maybe I'm getting better/smarter.
Happy game making
Thank you <3

Original thread: https://forums.rpgmakerweb.com/threads/exclude-some-numbers-from-random-number-variable.147502/