Is it possible to write a script that causes items to be lost with a specific variable?

I'd like to scope some items to a variable so that when I select another item excluding those items, I lose those items.
To do this, rather than selecting one item in the item increase/decrease event, I want to put the item value of the specified variable, but the item is selected unconditionally in the item increase/decrease event.

Can you make this into a script?

For example.

I have items A, B, C, and D.
If A or B or C is selected in the item selection event, a value other than D is put into the variable and the item selected by the player among A, B, and D disappears.
To make one by one, a variable is needed because there are actually about a hundred items.
I'm having a hard time figuring out exactly what you want to happen, so I'm referring to your example.

I have items A, B, C, and D.
If A or B or C is selected in the item selection event, a value other than D is put into the variable
What value other than D? The one the player selected? A random one? I don't understand this.
and the item selected by the player among A, B, and D disappears.
So are you just saying that you want to remove D regardless of which item the player chooses? If yes, is it always D, or does it depend on on the original selection?

If I choose A, I lose A and D, but if I choose B I lose B and C?
you might want to check for the script equivalents of the event commands. They are linked in a pinned topic for each specific maker.

A lot of the restrictions of event commands can be bypassed by using the script equivalent, and that might help you.
Not sure because as said above your description is rather confusing.
I'm having a hard time figuring out exactly what you want to happen, so I'm referring to your example.


What value other than D? The one the player selected? A random one? I don't understand this.

So are you just saying that you want to remove D regardless of which item the player chooses? If yes, is it always D, or does it depend on on the original selection?

If I choose A, I lose A and D, but if I choose B I lose B and C?
Sorry if my explanation is a bit convoluted.
I'm hoping the translator works correctly.

for example,
I have items A, B, C, D, E, F, G, ... Y, Z.
In the item selection event, the player chose item Z, but the correct item was A, B, C, or D.
At this time, we want to decrease the quantity of item Z that the player has selected.

The problem is that these items change every time, so I want to use a variable.

you might want to check for the script equivalents of the event commands. They are linked in a pinned topic for each specific maker.

A lot of the restrictions of event commands can be bypassed by using the script equivalent, and that might help you.
Not sure because as said above your description is rather confusing.

Sorry if my explanation is a bit convoluted.
I'm hoping the translator works correctly.

for example,
I have items A, B, C, D, E, F, G, ... Y, Z.
In the item selection event, the player chose item Z, but the correct item was A, B, C, or D.
At this time, we want to decrease the quantity of item Z that the player has selected.

The problem is that these items change every time, so I want to use a variable.

-
$gameVariables.setValue(variableId, value);
// Set variable ID 1 equal to 5
$gameVariables.setValue(1, 5);

$gameParty.loseItem(item, amount);
// Give the party 5x Item ID 1
$gameParty.gainItem($dataItems[1], 5);
-

I've been able to find some MZ scripts for incrementing and decrementing variables and items, but the problem is that I don't know how to combine them.
So you want a script to pick a random letter from A to Z inclusive, store it in a variable correctAnswer, then compare it against playerGuess, then if (playerGuess != correctAnswer) splice out the value of correctAnswer from array AtoZ?
So you want a script to pick a random letter from A to Z inclusive, store it in a variable correctAnswer, then compare it against playerGuess, then if (playerGuess != correctAnswer) splice out the value of correctAnswer from array AtoZ?

yes i can do that, but
I couldn't find a way to reduce the item.
yes i can do that, but
I couldn't find a way to reduce the item.

To make one by one, a variable is needed because there are actually about a hundred items.
Where is this list of items coming from? Is it the party's inventory, the database or some predefined pool of items?

In the item selection event, the player chose item Z, but the correct item was A, B, C, or D.
Also, how is the player inputting the answer since the answer can be one of four items out of 100 items?
At this time, we want to decrease the quantity of item Z that the player has selected.
In a Script command:
JavaScript:
const id = $gameVariables.value(2);
const count = 1;
$gameParty.loseItem($dataItems[id], count);
This means "lose 1 of the item with ID equal to the value of variable 2". E.g. if the value of variable 2 is 5, the party will lose 1 of Item 5. Is that what you wanted?
In a Script command:
JavaScript:
const id = $gameVariables.value(2);
const count = 1;
$gameParty.loseItem($dataItems[id], count);
This means "lose 1 of the item with ID equal to the value of variable 2". E.g. if the value of variable 2 is 5, the party will lose 1 of Item 5. Is that what you wanted?

Oh, this is the script I was looking for that makes an item shrinkable by a variable!

It's a bit of a pain to adapt to the game, but it works perfectly.
I appreciate your reply.
I'll make a good game. 🙂

Where is this list of items coming from? Is it the party's inventory, the database or some predefined pool of items?


Also, how is the player inputting the answer since the answer can be one of four items out of 100 items?

With help from the thread I found and applied the variable appropriate variable script.
Thank you for your reply as well. 🙂
Oh, this is the script I was looking for that makes an item shrinkable by a variable!

It's a bit of a pain to adapt to the game, but it works perfectly.
I appreciate your reply.
I'll make a good game. 🙂
When you say "it's a bit of a pain to adapt to the game" what exactly is your point of difficulty with adapting it?
I'm more amazed that they were able to implement that convoluted item gambling game but deducting an item from the party inventory was the roadblock.

Original thread: https://forums.rpgmakerweb.com/threads/is-it-possible-to-write-a-script-that-causes-items-to-be-lost-with-a-specific-variable.156749/