Chaos Project

RPG Maker => Event Systems => Event System Requests => Topic started by: ShadowBlaze on April 07, 2009, 08:17:59 pm

Title: [RESOLVED] Checking items in inventory
Post by: ShadowBlaze on April 07, 2009, 08:17:59 pm
Hi, I am making a craft system out of events and I would like to know how to check a players inventory for how many items of a certain type he has, for example:

Some Dude: How many bombs would you like to make? It reqiures 1 Coconut to make 1 Bomb.

*Input Number: 10* *Then store in variable 1*

KAY, so here how do you check if he has 10 Coconuts in his inventory? Not just 1 Coconut but checking for more than 1.

The condition branch option where you check if Coconuts is in the inventory but it only checks if its in the inventory not how many is in the inventory.

So can anybody help me out? I think it needs a script for this to work. Just make the script store the number of items in a variable and then condition branch it, if you know what i mean. >_>
Title: Re: Checking items in inventory
Post by: legacyblade on April 07, 2009, 10:22:36 pm
To check if the party has a certain number of an item (say coconuts ), use the following syntax in the "script" section of a conditional branch.

$game_party.item_number(item_id) == number


That would check to see if the item you're checking (who's ID you put between the parenthesizes) is equal to a certain number. Repalce the "==" with any other comparison sign (<<, >>, !=, <=, >=). If you want to assign the number of a particular item to a variable, do the following.

$game_party.item_number(item_id) = $game_switches[switch_number]


I don't have my computer, so I can't test these script calls out, but I'm pretty sure that's the correct syntax.
Title: Re: Checking items in inventory
Post by: Landith on April 07, 2009, 10:25:11 pm
Quote from: legacyblade on April 07, 2009, 10:22:36 pm
$game_party.item_number(item_id) = $game_switches[switch_number]


I don't have my computer, so I can't test these script calls out, but I'm pretty sure that's the correct syntax.


If he want's to assign it to a variable, shouldn't h-she use

$game_party.item_number(item_id) = $game_variables[variableID]


not switches..?
Title: Re: Checking items in inventory
Post by: legacyblade on April 07, 2009, 10:26:48 pm
oops, I'm tired. I meant variables. Thanks for catching that lani. Yes use the code snippet the poster above me provided, for it produces the desired effect.
Title: Re: Checking items in inventory
Post by: ShadowBlaze on April 07, 2009, 10:31:27 pm
Thanks Legacy, and Lani for correcting it
Title: Re: [RESOLVED] Checking items in inventory
Post by: Aqua on April 07, 2009, 10:33:19 pm
Um... you're supposed to use

$game_variables[variableID]= $game_party.item_number(item_id) 


If you're using the other one, then you'd be changing the number of item_id to what was in variableID.
Title: Re: [RESOLVED] Checking items in inventory
Post by: ShadowBlaze on April 07, 2009, 10:45:10 pm
Yea, Aqua is right! He just got you both LOL!
Thanks Aqua for CORRECTING their mistakes.