Count item script?

Isabella Ava

Veteran
Veteran
Joined
Sep 13, 2016
Messages
635
Reaction score
756
First Language
English
Hi there, i want to count item X (x is the item's ID stored in variable 1) to see how many of items X does player possess
and store the result into variable 2 (via Script call)
(can you show me the scripts for both situation that includes / not includes equipped items)
Thanks, please help T.T
 

dbchest

Beast Master
Veteran
Joined
Oct 1, 2013
Messages
434
Reaction score
306
First Language
English
Primarily Uses
RMMV
image is via event commands.

the script equivalent is $gameParty.numItems(item, includeEquip);

argument details:
item = $dataItems[itemId] i.e. the database item object itself.
includeEquip = boolean value specified as true or false.
 

Attachments

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
including equipped items:
Code:
$gameVariables.setValue (2, $gameParty._items[$gameVariables.value(1)]);
not including equipped items
Code:
var x = 0;
for (var i = 0; i<$gameParty.members().length; i++) {
if ($gameParty.members()[i].isEquipped ($gameVariables.value (1))) x++;
}
gameVariables.setValue (2, $gameParty._items[$gameVariables.value(1)] - x);
 

Isabella Ava

Veteran
Veteran
Joined
Sep 13, 2016
Messages
635
Reaction score
756
First Language
English
Wow thank so much @dbchest and @Poryg , I couldn't believe got replied that fast @.@
Both scripts you teach me works perfect.
Dbchest method "$gameParty.numItems(item, includeEquip);" is easier for a dummy like me though (while Poryg method #1 is shorter)
Thanks again
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
Of course it is, it is the one I used :) It just lacks content, but well... You get what you pay for and this site is free.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,045
Members
137,569
Latest member
Shtelsky
Top