how to count the equipped items like operand for control variables

hello


I wanted to know if there was a way to count the equipped items as operand when setting variables (for example with a call script or other).

fgfg.png



Currently it does never bother me much, I create my events or my quests as well, besides I never paid attention to it but I wondered if there was a solution to avoid frustrating my players.
👋 I think this should work in Control Variables > Script:
Spoiler: Script
JavaScript:
$gameParty.members().reduce((a1, c1) => a1 + c1.armors().reduce((a2, c2) => a2 + (c2.id === 5 ? 1 : 0), 0), 0);
Replace 5 with the ID of your armor. If you'd like to check for a weapon instead, replace armors with weapons.

This loops through all equipped armors of all party members, and keeps a running tally of the number of armors that have ID equal to the given number. The loop is done with reduce, here's technical details in case you're interested:
Hi, thanks a lot.

I will test this.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-count-the-equipped-items-like-operand-for-control-variables.131631/