How to Check for Multiple of the Same Item

KholeG

Snek
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
N/A
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.
 

KholeG

Snek
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
N/A
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

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,420
Reaction score
10,849
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:

KholeG

Snek
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
N/A
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,642
Reaction score
2,972
First Language
Tagalog
Primarily Uses
If urbusing the script call conditional, you could always do

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

KholeG

Snek
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
N/A
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,642
Reaction score
2,972
First Language
Tagalog
Primarily Uses
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:

KholeG

Snek
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
N/A
Alright, that makes a little more sense
 

Kes

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,420
Reaction score
10,849
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.
 

KholeG

Snek
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
N/A
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

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,420
Reaction score
10,849
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
29,003
Reaction score
6,684
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.
 

KholeG

Snek
Veteran
Joined
Apr 24, 2015
Messages
54
Reaction score
1
First Language
English
Primarily Uses
N/A
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

There's a new born faction in my country called "Sunda Empire" claiming they have right to rule over the earth and sun... I don't know what to feel...
Quon is watching you
Quon blessed your good efforts
I have tried, several times to understand how Markiplier is popular. You can't deny his popularity. I can only get through a few minutes of his vids, though. He's cringier than ANY cringe comp I've ever watched. When I was a kid, if you acted like that, 0 friends and 100% no dates for you. Times have changed XD
Sometimes you may feel helpless and defeated. But everyone loses from time to time. It's okay to be tired. Take a breather. Have a good cry if you need to. You gotta take breaks from your workout, or you'll collapse before you can get stronger.
So, my roommates wrote a news article in English, translated it into Bengali with google translate and now I'm helping them fix the monstrosity which was the result. Making English the medium of education is fine... but not to an extent that we forget how to write properly in our own language :")

Forum statistics

Threads
93,544
Messages
913,364
Members
123,075
Latest member
xCanopus
Top