How to Check for Multiple of the Same Item

DomTSVG

Certified Game Boi
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
RMVXA
Hi guys!

I was wonder if there was a way I could check for multiple items at the same time in one script call.

Basically I want to make a basic crafting system without a huge fancy script, and I want to be able to check for multiple items with an ID value and make sure the player has enough of the items with said ID value, all in one script call.

Ex:

Player wants to craft item "Fork Lance"

Required Items:

2 Flotsam

3 Wood

2 Shells

Script then checks the player inventory for all 3 item IDs and then checks that there are enough of said item in the inventory.

Thanks for the help!
 

Chiakscare

Resident Tifaholic
Veteran
Joined
Jul 24, 2014
Messages
489
Reaction score
148
First Language
English
Primarily Uses
You could bind items to variables, then have Conditional Branches that check for a total number of that item's variable.

You'd only really need a script to make a crafting menu that shows the items and highlights them, etc; there's custom menu scripts available already; if you wanted the variable checking in the script itself, that's pretty easy to code; it's also easy to do in pure eventing.
 

DomTSVG

Certified Game Boi
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
RMVXA
In another game I'd been working on I did the crafting by checking for every subsequent item and it was tedious.

I have no idea how to script and I don't actually need a menu. Is there no way to call it in event as a script like;

check item id in player inventory - true/false (once for each id)

x number of item id = y (again once for each id)

if both = true, activate switch ID z

I can get around it with item variable binding, but that can also be tedious and I'm not quite sure how to do it properly.
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
Script then checks the player inventory for all 3 item IDs and then checks that there are enough of said item in the inventory.
I think you mean event in this part, not script.  In RM scripts and events are 2 very different things, and you need to be clear in your terminology, otherwise a lot of confusion can occur.

If you don't want to use a script, it can be done in a straightforward way in events, but it will be tedious (probably very tedious).  You will have to choose which option you find least bad.
 
Last edited by a moderator:

DomTSVG

Certified Game Boi
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
RMVXA
I think you mean event in this part, not script.  In RM scripts and events are 2 very different things, and you need to be clear in your terminology, otherwise a lot of confusion can occur.
No, actually I do mean script. By script, I mean the in event script. As in you use a script call in an event, and I'm referring to the script being called.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
If urbusing the script call conditional, you could always do

If a and b and c and so on
 
Last edited by a moderator:

DomTSVG

Certified Game Boi
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
RMVXA
What do you mean by that exactly? In my description?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Ibmean you can do

If $game_variables[1] == 2 and $game_variables[2] == 5 and so... on

As a condition so you only use 1 conditional to check for all required itens
 
Last edited by a moderator:

DomTSVG

Certified Game Boi
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
RMVXA
Alright, that makes a little more sense
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
No, actually I do mean script. By script, I mean the in event script. As in you use a script call in an event, and I'm referring to the script being called.
That is not a script in RM  terminology.  It is, as you say, a script call (i.e. a call to a script).  Scripts are what you see in the script editor.  You do not have scripts in events.

You can, of course, use any form of words you like, but the chances are high that you will be misunderstood and potentially waste other peoples' time as they are quite likely to think you mean something else.
 

DomTSVG

Certified Game Boi
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
RMVXA
That is not a script in RM  terminology.  It is, as you say, a script call (i.e. a call to a script).  Scripts are what you see in the script editor.  You do not have scripts in events.

You can, of course, use any form of words you like, but the chances are high that you will be misunderstood and potentially waste other peoples' time as they are quite likely to think you mean something else.
My appologies, I'm still new to RM technology in the sense
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
np.

Everything ends up with its own specialist terminology/jargon and I think in some other engines eventing is called scripting, so it can get very confusing.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,370
Reaction score
7,678
First Language
German
Primarily Uses
RMMV
It can be done by pure eventing, and a lot faster than that:

check item id in player inventory - true/false (once for each id)


x number of item id = y (again once for each id)


if both = true, activate switch ID z
Use the control variable command to get the number:


control variable:game data:item in inventory


then use conditional branch var >= number needed


If the item is not in inventory, the control variable will load zero - no need to check the existance of the item in extra lines.


The script line from Engr. Adiktuzmiko above still needs to fill the variables with the numbers, so it only combines several conditional branches into one line.


I suggest you follow the first link in my signature (starting point) and work through the tutorials linked there, especially the "Variables Guide" as that will help you understand how to use variables more effectively.
 

DomTSVG

Certified Game Boi
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
RMVXA
Thank you Andar, this really helped. I've got my issue all solved!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

"You can thank my later", "But you haven't done anything", "Well, that's why ..."
Are we allowed to post about non-RPG Maker games?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

Forum statistics

Threads
105,884
Messages
1,017,243
Members
137,609
Latest member
shododdydoddy
Top