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,438
Reaction score
926
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,595
Reaction score
12,910
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 Posts

Latest Profile Posts

I'm currently being attacked by the RPG Maker Hydra: fixing one problem only to have two more rise to take its place.
Hey you! Yeah YOU! Whatcha doin' not backing up your projects? You a masochist or sumthin'? GO BACK UP YOUR PROJECTS! Sheeesh... Didn't think I'd hafta spell it out for yas.
now I need to determine, how MV determines if an auto tile is complete or not.
Edit:From what I can tell it uses Autotile kinds to do that.
Edit 2: The editor determines it and packs picture data for the engine....
Finished with the ground work for my class system, using Ellye's Class Change Equipment and Yanfly's Class Change Core plugins to implement an equip based subclass feature!
Hi people! I was wondering... Here in Brazil, we have a whats app group for we talk about rpg maker and our projects. A more informal way for we meet each other. Is there any whats app group out there? :)

Forum statistics

Threads
94,281
Messages
919,638
Members
124,014
Latest member
AnnuRavi
Top