How many Wepons and Armors?

Indsh

Veteran
Veteran
Joined
Oct 11, 2015
Messages
225
Reaction score
65
First Language
English
Primarily Uses
N/A
Is there an eqivilent for:

$gameParty.numItems(n)

That will do the same for wepons and armors, I have already created the work around just checking I'm not missing something simple or that dyslexia has failed me somewhere.

Cheers
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,117
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
What I'd suggest, unless you really need it to be a script, is to use a variable to get this.
  • Control Variables > Set > Game Data > Item|Weapon|Armor.

Otherwise: the numItems function takes an item object for its argument, not an item ID. The object reference will be from one of three arrays, depending on its type: $dataItems[n], $dataWeapons[n], or $dataArmors[n]. So, for example, this will return the number of weapon #3 that the party possesses:
Code:
$gameParty.numItems($dataWeapons[3]);
For reference, here's a snippet of code from the Control Variables command (found in rpg_objects.js):
Code:
Game_Interpreter.prototype.gameDataOperand = function(type, param1, param2) {
    switch (type) {
    case 0:  // Item
        return $gameParty.numItems($dataItems[param1]);
    case 1:  // Weapon
        return $gameParty.numItems($dataWeapons[param1]);
    case 2:  // Armor
        return $gameParty.numItems($dataArmors[param1]);
 

Indsh

Veteran
Veteran
Joined
Oct 11, 2015
Messages
225
Reaction score
65
First Language
English
Primarily Uses
N/A
As I thought was just missing some simple, cheers

(I do wish people in the Javascript section of the forum, especially the "Learning Javascript" section would quit trying to convince people not to learn by not applying the Javascript)
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,117
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
As I thought was just missing some simple, cheers
Happy to help! ^_^
(I do wish people in the Javascript section of the forum, especially the "Learning Javascript" section would quit trying to convince people not to learn by not applying the Javascript)
If I offended then I apologise; it was unintentional. :kaoswt2:

However, in case you're unaware: the code for all event commands can be found in rpg_objects.js, under the Game_Interpreter object. Every command's code is headed by a comment stating the command name, making it easy to look up the code version for any event command. Not to dissuade you from asking questions here, but it may save you a little time in future. =)
 

Indsh

Veteran
Veteran
Joined
Oct 11, 2015
Messages
225
Reaction score
65
First Language
English
Primarily Uses
N/A
@caethyril no offence taken, my appreciation was genuine!

I just think that there is a slight toxic air in these forums, that for some reason is geared towards not encouraging people to play/fail/learn when it comes to the scripting in RPG Maker.

What you said was really not that bad and was definitely solution based so I apologise also
 

BishoujoHelper

Veteran
Veteran
Joined
May 6, 2017
Messages
54
Reaction score
45
First Language
English
Primarily Uses
RMMV
Strangely, I was just about to go the scripting route myself, reasoning that there WAS a $dataWeapons based on there being a $dataItems that I had used elsewhere, but when I searched the forum for "count weapons" as my first try this post didn't show up for the ridiculous reason that the OP didn't spell it correctly. Found this post on a follow-up search for $dataWeapons.
I'm not sure if I should facepalm for not thinking to look in the Control Variables command when I couldn't find a way to count weapons or armor in the Conditional Branch command.
 

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

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,476
Members
137,824
Latest member
dobratemporal
Top