MZ arrays item?

Hello. Please help with arrays.
I want to implement one mechanic...
The gist:
I need to check if there are items in the party inventory and if so, how many.

I created 5 items under numbers 23, 24, 25, 26, 27

I need to somehow put them in an array, and in the maker check this array, if at least one item is there, then call a dialog.

I don't know JS, but I suppose there is some kind of thing: $gameItem[n] or no. =(

With variables I could do something like: $gameVariables.value(var, [23, 24, etc])

but I don't know how to make an array of items =(

Please help.
I think this may help you (it uses arrays); it's basically for MV but MZ works the same with JS.
Something like
Code:
var items = [21,22,23,24];
for(var i in items){
if($gameParty.hasItem($dataItems[items[i]])){
$gameMessage.add("You have at least one of those items."); break;
}}
This is incomplete as it's not clear what you want to happen. You say you want to check how many but then say you just want to check if the party has any item at all of a given pool of item ids.
I have a task, something like gifts to NPCs.
I need to check if I have these items in my inventory, and if so, display a choice of what exactly to give from what I have.

Something like:
If: there are 2 items, for example, 23 and 25
Display the choice:
1. Give 23
2. Give 25

Accordingly, if there were other items, then display them in the "choice" too.

So far I've found how to make an array from a variable.

#0091 gift = [21,22,23,24]

Now need to check whether the variable is empty or not.
You need to clarify what you want this script to actually do, because I interpreted your OP as "Create an array of item ids, then check if the party has any of those items in their inventory, if so, display a message"

Edit: You changed your above post and that is a bit more complicated because now you're not just checking if there is any item and stopping at the first result, but going through the entire array of items and pushing each item that passes the "party has it" check into a dynamically populated choice menu, which you may need a plugin for.
You need to clarify what you want this script to actually do, because I interpreted your OP as "Create an array of item ids, then check if the party has any of those items in their inventory, if so, display a message"

Edit: You changed your above post and that is a bit more complicated because now you're not just checking if there is any item and stopping at the first result, but going through the entire array of items and pushing each item that passes the "party has it" check into a dynamically populated choice menu, which you may need a plugin for.
Event (NPC)
Should check what gifts are in the inventory (23 or 25 or 24, etc.)
And display those that are in the selection.
I don't think a plugin is needed for such a task, it's a couple of lines of code.
Check (NPC Event) and
Display selection: checking availability using a loop.

I tried to put gifts in variables. That is, when buying a gift, add 1 to the variable.
But I still didn't understand how to do this in the maker.

If in more detail, then something like this:
Variable 1 = gift 23
Variable 2 = gift 24

And then, when buying, for example, "gift 24" 1 piece, += Variable 2.

But when buying, the variable does not change. =(
I will continue to think. Thank you for your attempt to help.
what version of rpgmaker are you using? it sounds like you want something like HIME's conditional choice plugin so that you can have your 5 choices and then hide each one if the party doesnt have the corresponding item
what version of rpgmaker are you using? it sounds like you want something like HIME's conditional choice plugin so that you can have your 5 choices and then hide each one if the party doesnt have the corresponding item
MZ version
I don't think a plugin is needed for such a task, it's a couple of lines of code.
Check (NPC Event) and
Display selection: checking availability using a loop.
With all due respect, your programming knowledge as shown in this topic isn't enough to determine that. You want a dynamically populated choice menu, which may require a plugin as that's not built into the engine
With all due respect, your programming knowledge as shown in this topic isn't enough to determine that. You want a dynamically populated choice menu, which may require a plugin as that's not built into the engine
I appreciate your opinion. But I think differently.
I have enough knowledge in programming, unfortunately I am not familiar with Java script. =)

I solved the problem.

I did not count any arrays, but simply did this:

Code:
If there is gift 1

     If there is gift 2:

             Output choice 1

             Output choice 2

Else:

      Output choice 1

And it works.
Thank you for your time.

Original thread: https://forums.rpgmakerweb.com/threads/arrays-item.171558/