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,379
Reaction score
1,784
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,379
Reaction score
1,784
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
46
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.
 

Latest Threads

Latest Posts

Latest Profile Posts

I almost thought it wouldn't happen, but a miracle has occurred, and IT'S HAPPENING!!!
xabileug wrote on thenerdmansion's profile.
TMCard - tomoaky
Hi i am currently working on a personal game using tomoaky TMCard in MV. i already have several modifications to it..

Screenshot-2021-04-18-at-19-32-48.png


Rest your weary legs in the Dancing Fox Inn!
Love to kick back and gamemak at the end of the day.
yay, i finally got around adding a profile pic! :guffaw:

Forum statistics

Threads
110,598
Messages
1,054,593
Members
143,731
Latest member
NateThe8
Top