hey guys, I am using mog treasure popup in my project and i am having a little difficulty calling the gain item command from script call.
to explain i have an array of numbers that i get a random entry from and add that entry to the inventory, the reason i am not using
here is my code:
if anyone can tell me what i am doing wrong that would be awesome, thanks in advance
to explain i have an array of numbers that i get a random entry from and add that entry to the inventory, the reason i am not using
$gameParty.gainItem($dataItems[loot], 1); is because it does not call the treasure popup like it would in a normal gain item callhere is my code:
JavaScript:
//gain random item and call the mog treasure popup
Array.prototype.random = function () {
return this[Math.floor((Math.random()*this.length))];
}
const pool = ["75",
"77",
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
"83"
];
let loot = pool.random(); //ID OF ITEM YOU WANT;
var incDec = 0; //0 FOR INCREASE, 1 FOR DECREASE;
var constVar = 0; //0 FOR CONSTANT, 1 FOR VARIABLE;
var value = 1; //CONSTANT VALUE OR VARIABLE ID;
if (loot != null) {
$gameMap._interpreter._params = [loot, incDec, constVar, value];
$gameMap._interpreter.command126();
//$gameParty.gainItem($dataItems[loot], 1); //does not work with treasure popup
$gameSwitches.setValue(24, true); //not in use right now
$gameVariables.setValue(93, loot); //not in use right now
}