Okay, maybe you could set a variable to the amount of a particular consumable item like this:
Code:
$game_variables[X] = $game_party.item_number($data_items[Y])
Note: I would try to use the same variable ID number that corresponds to the database number for the items, just to be less confusing.
Then you could check to see if all the variables have a value greater than one like this:
Code:
[variableid, variableid, variableid].some(function(id) { return $gameVariable.value(id) === value}){
Example Use:
[121, 122, 123, 124, 125, 126, 127].some(function(id){ return $gameVariables.value(id) === 1})
This means that from Variables 121 - 127, it will check if one or more of them has the value of 1.
Check Master script call list.
Now the trick would be use whichever variables have value greater than or equal to 1 as a pool to then randomly choose one variable. This is the part that has me stumped at the moment.
I know you can create a pool of numbers, then pick one of those at random, like this:
Code:
pool = [1, 2, 3, 4];
item = pool[Math.floor(Math.random()*pool.length)];
The issue then is how to get those variables that are only greater than or equal to 1 into the pool.
But you could use 'item = x' and create a bunch of nested conditional branches to then create the effect that you want to happen.
As for the force use of an action/item, that only works in battle. So if you're wanting this to happen on the map then you would simulate what the item does within the event. For example, the item used is a potion that adds 500 HP; you will use the event to increase actors HP by 500, play the animation ID that corresponds to the item on the actor, and finally remove the item from player inventory. Essentially, you're just making it
look like the player used the item.