So in my game there is a shop that sells random items, weapons, and armor. I already have a special script running that allows this randomized shop to work. Here it is.
"Var ID" determines which variable the random shop will use, type determines which type of item is chosen, (1 for items, 2 for weapons, 3 for armor) min and max are the lowest and highest IDs of a weapon or armor that you want to randomize, and inv determines if you can sell or not. (0 = Allow, 1 = Deny) Seems simple enough, right?
However, in all three of the categories, different types of items, weapons, and armor are divided by blank items that are named "-----------------------" and used as dividers. I do not want the random selection script to choose any of these blank items. I know that I can make a loop and then put in a conditional branch for every ID I don't want chosen and if that ID I don't want is chosen the loop repeats until I get the result I wanted, but that will take ages as for some of the categories there are almost 100 blank items and I don't want to make an conditional branch for every one! Is there a way to have conditional branches be able to select multiple variable numbers (not the actual variables, just the numbers like 2, 5, 7, ect) at once out of a pool of numbers? An example of this would be a conditional branch that says "If variable x = 2, 5, 7, 12, 18, 24, 33...or 211, then play result 1. If else, play result 2." Another possibility would be to alter the command to exclude certain IDs when randomly choosing numbers. Is there any was to acomplish this in base MV or is there a specific plugin I'll need? Thanks.
-KrimsonKatt
var id = x, type = y, min = z, max = a, inv = b;
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);
$gameVariables.setValue(id, array);
"Var ID" determines which variable the random shop will use, type determines which type of item is chosen, (1 for items, 2 for weapons, 3 for armor) min and max are the lowest and highest IDs of a weapon or armor that you want to randomize, and inv determines if you can sell or not. (0 = Allow, 1 = Deny) Seems simple enough, right?
However, in all three of the categories, different types of items, weapons, and armor are divided by blank items that are named "-----------------------" and used as dividers. I do not want the random selection script to choose any of these blank items. I know that I can make a loop and then put in a conditional branch for every ID I don't want chosen and if that ID I don't want is chosen the loop repeats until I get the result I wanted, but that will take ages as for some of the categories there are almost 100 blank items and I don't want to make an conditional branch for every one! Is there a way to have conditional branches be able to select multiple variable numbers (not the actual variables, just the numbers like 2, 5, 7, ect) at once out of a pool of numbers? An example of this would be a conditional branch that says "If variable x = 2, 5, 7, 12, 18, 24, 33...or 211, then play result 1. If else, play result 2." Another possibility would be to alter the command to exclude certain IDs when randomly choosing numbers. Is there any was to acomplish this in base MV or is there a specific plugin I'll need? Thanks.
-KrimsonKatt