Hey! I'm trying to use this small script for randomizing shops that I found, but I want to reference a variable and not a set number. The script is this:
You're meant to only change the 0s in the first line. What I want is to replace the max to the value of a variable that is added to with consumables in the game.
I tried
but it causes a crash as soon as you try to call the shop. I am a total novice when it comes to programming though and just pieced this attempt together reading a bunch of other scripts lol
Would really appreciate any advice! Thanks!
Code:
var id = 0, type = 0, min = 0, max = 0, inv = 0;
var array = [], temp = [], rand;
for(i = 0; i < inv; i++) {
do { rand = Math.floor(Math.random()*(max-min+1)+min);
} while (temp.indexOf(rand) > -1);
temp[i] = rand;
array[i] = [type, rand, 0];
}
if(Array.isArray($gameVariables.value(id)))
var array = $gameVariables.value(id).concat(array);
You're meant to only change the 0s in the first line. What I want is to replace the max to the value of a variable that is added to with consumables in the game.
I tried
Code:
let giftsGiven = $gameVariables.value(88);
var id = 81, type = 0, min = 0, max = 'giftsGiven', inv = 0;
but it causes a crash as soon as you try to call the shop. I am a total novice when it comes to programming though and just pieced this attempt together reading a bunch of other scripts lol
Would really appreciate any advice! Thanks!