Inventory Item Count Detection?

QueenTeaYT

Veteran
Veteran
Joined
Nov 8, 2019
Messages
45
Reaction score
11
First Language
English
Primarily Uses
RMVXA
I want an event to occur once it detects X amount of Y item. Is this possible? I only know how to use the detect item for 1 count.

EDIT: To be more specific, I want to an event to occur once the player has collected 40 flowers.
 

Dreyliam

Villager
Member
Joined
Feb 7, 2019
Messages
17
Reaction score
5
First Language
portuguese
Primarily Uses
RMMV
Yes, for this you will need a variable to be counting the number of items, you can set this value to the variable causing an event to change its value, when adding the value that will change in the variable, leave "set" never on add or subtract, the event that will change the value of the variable must be in parallel, i rather to use a common event for this!
 

Shiro-chan

Friendly Neighbourhood Neppy Maid
Veteran
Joined
Aug 7, 2018
Messages
128
Reaction score
32
First Language
German
Primarily Uses
RMVXA
Do this scriptcall:
Code:
$game_variables[X] = $game_party.item_number($data_items[Y])
Where X must be the variable you are using, and Y the item ID you want (i.e. your flower item). Put the code wherever you think is most fitting to start your event; I suggest an autorun event whose page checks if you have in fact any flowers, then it runs that scriptcall and, if positive, allows your actual event to run (else it just Erases itself).
 

Thorgaaz

Veteran
Veteran
Joined
Aug 14, 2016
Messages
47
Reaction score
2
First Language
German
Primarily Uses
Yup i also would use the variable method. Create a variable, each pick flower event counts +1 and has an conditional Branch which say, if the variable reach 40 do what you want it to do.

You can also give that Conditional Branch to other events like for example the NPC which he has to bring the flowers.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,353
Reaction score
12,855
First Language
English
Primarily Uses
RMMV
What is the event you want "to occur"? What does "to occur" mean? Is the event on this map, and do you want it to start doing something straight away, as soon as you get #40? Or is it on another map, or is it on this map and you just want it to do something different when you interact with it after getting #40?

The easiest way will be to increment the count each time a flower is picked, as shown above (use Control Variables, not a script call), followed by a conditional branch to see if the variable is 40, and if it is, turn on a switch. Then give the event you want "to occur" a second page conditioned by that switch, and set it up however you need to (autorun if it's nearby and you want it to do something straight away, or action button if you just want it to behave differently on the next time you interact with it).

The reason I say not to use a script call is that Control Variables already has a way to set a variable to the number of items in your inventory. It's in the Game Data section of the command.
 

Shiro-chan

Friendly Neighbourhood Neppy Maid
Veteran
Joined
Aug 7, 2018
Messages
128
Reaction score
32
First Language
German
Primarily Uses
RMVXA
What is the event you want "to occur"? What does "to occur" mean? Is the event on this map, and do you want it to start doing something straight away, as soon as you get #40? Or is it on another map, or is it on this map and you just want it to do something different when you interact with it after getting #40?

The easiest way will be to increment the count each time a flower is picked, as shown above (use Control Variables, not a script call), followed by a conditional branch to see if the variable is 40, and if it is, turn on a switch. Then give the event you want "to occur" a second page conditioned by that switch, and set it up however you need to (autorun if it's nearby and you want it to do something straight away, or action button if you just want it to behave differently on the next time you interact with it).

The reason I say not to use a script call is that Control Variables already has a way to set a variable to the number of items in your inventory. It's in the Game Data section of the command.
That is really just a matter of efficiency. Do you want the scriptcall and thus use only one command, or have to consider the variable incrase every time? In a project that would allow the former to be used with no ill effect and a LOT of such situations, I'd always go for the former.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,353
Reaction score
12,855
First Language
English
Primarily Uses
RMMV
Do you want the scriptcall and thus use only one command, or have to consider the variable incrase every time?
The script call does not mean you only have to do it one time. You still don't need a script call to check the number of items held. There is an event command that will do that - Control Variables > Game Data > Item [X] in Inventory.

Whether you have to do it once only or every time a flower is picked depends on whether the event is to be activated straight away (change sprite or do autorun, for example), or whether it's just when the player interacts with it. If it's only that the event does something different next time you interact with it ("Oh, you've got 40 flowers, okay give them to me and I'll give you this trinket in exchange"), that can be done with a single check on the event itself, with a conditional branch. But if it's to activate straight away, you're going to have to do the check after every flower is picked.
 

QueenTeaYT

Veteran
Veteran
Joined
Nov 8, 2019
Messages
45
Reaction score
11
First Language
English
Primarily Uses
RMVXA
The script call does not mean you only have to do it one time. You still don't need a script call to check the number of items held. There is an event command that will do that - Control Variables > Game Data > Item [X] in Inventory.

Whether you have to do it once only or every time a flower is picked depends on whether the event is to be activated straight away (change sprite or do autorun, for example), or whether it's just when the player interacts with it. If it's only that the event does something different next time you interact with it ("Oh, you've got 40 flowers, okay give them to me and I'll give you this trinket in exchange"), that can be done with a single check on the event itself, with a conditional branch. But if it's to activate straight away, you're going to have to do the check after every flower is picked.
Ahh sorry for the late reply. >.< The event I want to happen after collecting 40 flowers is a cutscene (probably a manual event, not a movie). I don't mind how complicated I have to get for this to happen, so thanks for all the feedback!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,353
Reaction score
12,855
First Language
English
Primarily Uses
RMMV
So on each flower event, just call a common event. In the common event, add the flower, check how many there are in inventory, and if 40 or more, play the cutscene. Then have a way to turn it off so you can't keep picking flowers, or if you do, the cutscene doesn't keep playing.
 

Dreyliam

Villager
Member
Joined
Feb 7, 2019
Messages
17
Reaction score
5
First Language
portuguese
Primarily Uses
RMMV
all you want to do is quite simple really
 

QueenTeaYT

Veteran
Veteran
Joined
Nov 8, 2019
Messages
45
Reaction score
11
First Language
English
Primarily Uses
RMVXA
So on each flower event, just call a common event. In the common event, add the flower, check how many there are in inventory, and if 40 or more, play the cutscene. Then have a way to turn it off so you can't keep picking flowers, or if you do, the cutscene doesn't keep playing.
Do you have any idea how I could "turn it off?"
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,353
Reaction score
12,855
First Language
English
Primarily Uses
RMMV
How many flowers do you have? If there are only 40, then it's easy - once you reach 40, it means you've picked all the flowers, so there are no more to pick and no more events to call the common event.

If more than 40, then it depends on what you want to do with the extra flowers. Do you want the player to be able to keep picking them? If you do, then make your common event look like this:
Code:
If Switch X (Played Cutscene) is OFF
  Add flower to inventory
  Turn on self switch A (this will turn on the self switch for whichever event called the common event)
  Check number of flowers
  If 40 flowers picked
    Play Cutscene
    Control Switches: X (Played Cutscene) = ON
  End
End
This way, each time you pick a flower and call the common event, it will check to see if the cutscene had already played. If it has, nothing will happen. If it hasn't, it'll do the check for how many flowers, and if the required number, will play the cutscene and turn on the switch to prevent the cutscene playing again.

If you don't want the player to be able to keep picking flowers, then give each flower event THREE pages.
Page 1 is the flower, no condition, action button trigger, and command to call the common event.
Page 2 is the flower, condition is the switch that was checked and turned on in the common event, action button trigger, no commands.
Page 3 is no sprite, self switch A as condition

In this case, each time you pick a flower, the common event is called and the flower disappears. When you have 40 flowers, the remaining events will active the second page, preventing you from picking any more flowers.
 

QueenTeaYT

Veteran
Veteran
Joined
Nov 8, 2019
Messages
45
Reaction score
11
First Language
English
Primarily Uses
RMVXA
Oh, okay! There are only 40 flowers so luckily it's the easy solution haha. Thanks for explaining. :)

I'm having trouble figuring out the common event to detect it though. I used a conditional branch that would activate if my variable "picked flower" was equal to 40, then plays the cutscene. Each flower calls this common event to check it, but nothing happens once I've collected all 40 flowers.
 

Shiro-chan

Friendly Neighbourhood Neppy Maid
Veteran
Joined
Aug 7, 2018
Messages
128
Reaction score
32
First Language
German
Primarily Uses
RMVXA
Why not put it on a different event that has autorun as its condition and requires the variable to be 40+?
 

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

Latest Threads

Latest Posts

Latest Profile Posts

What is your problem procrastination and distraction?
nio kasgami wrote on Galenmereth's profile.
bro U back! :D
Procrastinated so badly that i accidentally painstakingly recreated small details from RPG Maker 2000 into MV instead of working on my normal project, whoops.
Just imagine, MZ got released while still on summer sale and they decided to discount their game. lol.
Now that I found an accessible composing software, all the melodies that only lived inside my head so far can come to life. I LOVE this.

Forum statistics

Threads
99,283
Messages
963,830
Members
130,891
Latest member
Henzir
Top