How to roll a random number between two variables

wickednick

Veteran
Veteran
Joined
Feb 19, 2016
Messages
65
Reaction score
3
First Language
Nick
Primarily Uses
So I want to roll a random number between two variables for encounters. I found this script on the forums but I can't seem to get it to work.

$gameVariables.value(13);

$gameVariables.value(14);

Math.random();

Math.min(13, 14) + rd * Math.abs(14 - 13);

$gameVariables.setValue(11, value);

thanks
 

Soulrender

Jack Of All Trades
Veteran
Joined
Jan 12, 2019
Messages
770
Reaction score
420
First Language
Poland
Primarily Uses
RMMV
use this:

Math.floor(Math.random() * (max - min + 1)) + min;

put in place of max and min your variables and set it as value to your variable #11
 

wickednick

Veteran
Veteran
Joined
Feb 19, 2016
Messages
65
Reaction score
3
First Language
Nick
Primarily Uses
Thanks a bunch. I tried making something like that, but couldn't figure it out and the script I found seemed overly complicated for what I wanted to do.
 

wickednick

Veteran
Veteran
Joined
Feb 19, 2016
Messages
65
Reaction score
3
First Language
Nick
Primarily Uses
So I had to modify it a bit to get it to work like I wanted so it would actually pull the numbers from the two variables. Thanks again.
Math.floor(Math.random() * ($gameVariables.value(14) - $gameVariables.value(13) + 1))+$gameVariables.value(13);
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Ami
--- Diary ---

M.Mage: It's the F.Mage's Diary. While she isn't here,i can read it.

May, 10: I'm hurt after the battle with the Minotaur. But luckily,F.Healer heal me with her Heal-2. That why,i Fall in Love with her.

M.Mage: Eh???
So... some of my Desktop hardware has kicked it apparently (still trying to figure out what and how at the moment :/ ) .... yay?
Stream will be live shortly with some Darkest Dungeon! Feel free to drop by!
Made a HUGE (YYOOOOJJ) Update to Monstructs and moving towards a Steam Early Access release!
A skill type called: "Rumagic". The intention is Magic with Rum(that pirates drink)
Does it sound strange in English?

Forum statistics

Threads
104,220
Messages
1,004,778
Members
135,728
Latest member
Naga23
Top