Resource item counter witout scripting

CavaliereHoScudo

There is life after the Game Over
Member
Joined
Dec 14, 2017
Messages
19
Reaction score
8
First Language
Italian
Primarily Uses
RMVXA
Question: I want to be able to count how many of an item the player has with events, and rejecting a player's attempt to progress further if they have less than required for that particular action.

Situation: you, the player, need a certain item quantity to create stuff, or to progress in the game. Let's say you need 10 Wooden Splinters to make a weapon called Makeshift Scratcher.
You drop the Wooden Splinters from common mobs, so far all good. Then what? You'll need to talk to a NPC that counts how many Wooden Splinters you have, and if you have less than 10 it will say "nope you don't have enough", while having 10 or more will let them build the Makeshift Scratcher for you.

Now, this is just an example of a situation I'm describing. I'm pretty sure this can be done fairly easily with a script, but I'm still working on that project which I want to use no scripts on, so I was wondering if anybody had an alternative solution. Regretfully, I found out that it really is no easy task at all.

I came up with this alternative:

You talk to a quest NPC that will act as a "converter". If you still have at least one of said items, the game will subtract one of them from the stack and add 1 to a variable that will serve as your "currency", otherwise the game will break the loop as you have nothing to convert anymore. The conversion can be done by the quest NPC itself, or a secondary one.
Once you're done with the conversion, speak to the quest NPC again and he'll do a quick check of the variable: if it's greater than the amount required, yay quest done, if it's not, nay. Obviously, you'll probably need another NPC that keeps track of how many you have (or it can be the quest NPC itself), or an item that will do that when used. How would you know if you've met the quota yet or not without it?

A slightly different version of this procedure puts everything into the same quest NPC, but it has the item-to-variable conversion and the check in the same operation and it stops once you have no items, or you have met the quota.
Say you have 5 Splinters. Problem: it cannot check if you have 10 right away, because it doesn't know how to count and it would have to convert them with the above mentioned operation, requiring another line that converts the variable value back into items if the check fails. It may use a variable to count how many Splinters you have, so it can check that first, and run the conversion if it's less than 10 - or it may skip this check and start converting the items right away.
Regardless of what you would decide to do, at this point it will check if you have at least one Splinter, and if you do it will convert them into a variable, then check if that meets the criteria. If if doesn't (and in this case it doesn't because, as we said, you only had 5 Splinters and the variable now reads "5"), it won't let you continue.

The first alternative keeps the conversion and the check operations separate, but it doesn't burn the items unless you intentionally run the conversion. The second alternative puts it all together but burns your items as soon as you run the check because it also converts them.

This are really complicated and pretty easy to get lost into, I understand that, and for this reason I was wondering if you had any simpler solutions for this. Any help is appreciated.

(feels like being back in programming classes - only, a very dumbed down version of them)
 

mishakoc

Professional Procrastinator
Veteran
Joined
Jan 1, 2019
Messages
143
Reaction score
871
First Language
Czech
Primarily Uses
RMMV
Control variables→set to game data→item wooden splinters (in inventory). That sets the variable to the item quantity in your inventory.
You're right, just like programming classes - trying to make complicated stuff when there's already a built-in function for solving the problem. :)
 

CavaliereHoScudo

There is life after the Game Over
Member
Joined
Dec 14, 2017
Messages
19
Reaction score
8
First Language
Italian
Primarily Uses
RMVXA
Control variables→set to game data→item wooden splinters (in inventory). That sets the variable to the item quantity in your inventory.
You're right, just like programming classes - trying to make complicated stuff when there's already a built-in function for solving the problem. :)
Wait, so there's already a function enabling a variable to count how many units of a specific item you have?

Oh boy, why did I never find out about this? I learned something new today. Thanks a lot :D

Oh, right, forgot to ask: should I put the variable in a Parallel Process event in order to have it always up to date? Or should I initialise the variable every time the game needs to check how many I have?
 
Last edited:

mishakoc

Professional Procrastinator
Veteran
Joined
Jan 1, 2019
Messages
143
Reaction score
871
First Language
Czech
Primarily Uses
RMMV
Its usually suggested to use as little parallel processes as possible so the game doesn't lag too much. So unless the variable changes all the time (like XY position), you don't need to use that.
Every time you need to make the check (generally only if you are interacting with the quest giver event), rewrite the variable and then check its value in the conditional branch.
If you need to have it up to date all the time (like in a quest log) but it doesn't change much, you could update it after every time the player gets the item or uses a shop.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
@CavaliereHoScudo since this question is quite basic, I strongly recommend you to follow the beginner tutorials. The reason I am saying this is because there is a very similar thing in one of them (if I am not mistaken it is in the one by Touchfuzzy that you can find here). There is also another very good one by Andar that you can find in my signature (it should also include a link to the other one I mentioned). Going through them before you start making something more complex is very beneficial on the long run.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,599
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
Oh, right, forgot to ask: should I put the variable in a Parallel Process event in order to have it always up to date? Or should I initialise the variable every time the game needs to check how many I have?
Update when you need. It's a good practice.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,455
Members
137,821
Latest member
Capterson
Top