different ''random'' option for variables

Heyo fellas,

Currently im in a bit of pickle, the random option for variables doesnt have what I need. Basically:

I need not for the random option to choose a random number between x and x, but i want it to choose a random number between specific set numbers like ''1,2,5,8,10,11'' for example.

Hope someone can help,
Thanks!
You can just set the variable to the following script: [1, 2, 5, 8, 10, 11][Math.randomInt(6)]

Explanation in case you're not familiar with Javascript: The first part in square brackets is the array with the numbers you want it to pick from, and the second part in square brackets is the element of the array. Math.randomInt is a function defined in rpg_core.js and it "[g]enerates a random integer in the range (0, max-1)." So you get a random number between 0 and 5 that specifies which element of the array will be picked.

If the length of your array changes, i.e., you want to choose from fewer or more numbers, be sure to change the number in parentheses in the Math.randomInt function so that it's always Math.randomInt(number of numbers in the array).
Thanks @SeaPhoenix ! This was super helpful for my project as well. xoxo
exactly what i was looking for. Thanks alot!

Original thread: https://forums.rpgmakerweb.com/threads/different-random-option-for-variables.85223/