How to roll a random number between two variables

wickednick

Veteran
Veteran
Joined
Feb 19, 2016
Messages
66
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
840
Reaction score
470
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
66
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
66
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 Posts

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,033
Messages
1,018,441
Members
137,820
Latest member
georg09byron
Top