Return # of equips of certain type?

Status
Not open for further replies.

ZServ

Veteran
Veteran
Joined
Jun 16, 2014
Messages
255
Reaction score
70
Primarily Uses
I.E., you have 5 helmets in your inventory. Is there a quick way to count how many there are, including duplicates? I'm pretty sure you can, but I'm not sure where to find the details on the various equip types in order to do such a thing.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,461
Reaction score
948
First Language
EN
Primarily Uses
RMMV
To count the number of one particular item in the database, you can use Control Variables > Game Data > Item|Weapon|Armor. Nice and easy~ ^_^

If not, then it's scriptin' time! First, note that there are three equippable item types on the Types tab in the database: Weapon Type, Armor Type, and Equipment Type. (The corresponding properties in the game code are wtypeId, atypeId, and etypeId.) If you don't mind ignoring equipped items, I think the following snippets should work in the Control Variables > Script box; just pick the one corresponding to the appropriate type and change the number at the start as needed:
  • Count possessed Weapons of Weapon Type #1:
    Code:
    var wtypeId = 1; $gameParty.weapons().reduce(function(t, w) { return t + (w.wtypeId === wtypeId ? $gameParty.numItems(w) : 0); }, 0)
  • Count possessed Armors of Armor Type #2:
    Code:
    var atypeId = 2; $gameParty.armors().reduce(function(t, a) { return t + (a.atypeId === atypeId ? $gameParty.numItems(a) : 0); }, 0)
  • Count possessed Armors of Equipment Type #3:
    Code:
    var etypeId = 3; $gameParty.armors().reduce(function(t, a) { return t + (a.etypeId === etypeId ? $gameParty.numItems(a) : 0); }, 0)
 

ZServ

Veteran
Veteran
Joined
Jun 16, 2014
Messages
255
Reaction score
70
Primarily Uses
Ah, perfect! This is incredibly helpful! Thank you a ton <3
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
12,607
Reaction score
12,928
First Language
English
Primarily Uses
RMVXA

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Coffee + Silk Coconut Milk + Splenda Zero = Not ..... awful :/ .
My new RPG Maker music pack, Emotional: Redemption, is now in progress and will be coming to RPG Maker soon. It is an album that focuses on emotional themes including the darker forms of sorrow and despair. Below is a demo of a composition from the album.

Please watch out for your hands when handling chests! XD Did this a few days ago, it was fun to animate

Apparently, it's illegal to be drunk on licensed premises: pubs, etc. It's illegal for keepers of public houses to permit drunkenness and disorderly conduct. lol.
Pillow Hero - A 16-bit arcade styled puzzle game, update 0.5 is live now on Itch.io! --> https://bifrost09.itch.io/pillow-hero

Forum statistics

Threads
94,441
Messages
920,959
Members
124,254
Latest member
narongkron1
Top