Variable with random numbers as a script
RPG Maker MV Support$gameVariables.setValue(16, -10 + Math.randomInt(16))RMMV's
Math.randomInt(n) generates a random number from 0 to n-1 (inclusive). So Math.randomInt(16) returns a random number in the range 0~15.What if I wanted a random number from 155-157 AND 171-174 but only want 1 return value from those seven possibilities?
var list = [155, 156, 157, 171, 172, 173, 174]
$gameVariables.setValue(var id, list[Math.randomInt(7)])
Ah, I just answered this on your thread here, pretty much the same as what AmVa suggested:
forums.rpgmakerweb.com
Script for random variables
Trying to figure out how I can script a variable to randomly select between a set group of numbers, out of sequence. EG: 155 to 157 AND 171-174 EG: 181, ,189, 193, 194, etc.
forums.rpgmakerweb.com
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/variable-with-random-numbers-as-a-script.154651/
