RPG Maker MV

RPG Maker MV

Not enough ratings
Shops with Stocks ("Cheating" way)
By MAKAIROSI
I have seen many people wanting to put limited stocks in their shops, however i have never seen a reliable answer that doesn't contain any bugs. Well, this is still not an answer exactly, it's the "cheating" way to do it, but it does work! Keep on reading to find out how.
   
Award
Favorite
Favorited
Unfavorite
First things first
To do this we are going to need Yanfly's plugin "More Currencies" which, in turn, requires Yanfly's plugin "Shop Core".

We are also going to need to allocate different variables for each of the items we want to have limited stock.

For this guide, we will use a shop with 4 items:

Item 1's stock is stored in variable 1
Item 2's stock is stored in variable 2
etc.

Now, in the beginning of your game, when you set your starting variables, make sure to set the "stock" variables to the stock you want the shop to have.

For this example, we will say the shop will have 4 of each item. So we set variables 1..4 to the constant 4.
The cheating part
Following the help file of the "More Currencies" plugin, we add the according notetags to our items.
Item 1 gets the notetag <VARIABLE 1 BUY PRICE: 1>
Item 2 gets the notetag <VARIABLE 2 BUY PRICE: 1>
etc.

I think the reason i call this "cheating" must have become obvious by now: We are actually PAYING the item with an extra currency. When that currency runs out the item will be unavailable. So the currency works as if it's monitoring the stock of the item!

Now, following the help file we can put the names of variables inside <<>> to make them hidden. So you will notice that a number appears when you're buying the item - since we're practically paying it with extra currency. To remove this number we can go to the plugin's parameters and set the font size to 1 (that's the minimum).
Pros and Cons
Pros:

You can set a shop to have a limited stock of items.
You can restock the shop at your convenience by changing the corresponding variable.
You can add or remove stock depending on events (for example freeing the blacksmith provides the stock of "iron" by 1 each day.)
You haven't written a single line of code and everything is within Yanfly's terms.

Cons:

You (almost) completely negate the usage of other "extra" currencies.
You will need a new variable for every new item whose stock you want maintained.
Object variables are not accepted.
Your shop is going to look a bit weird (font size 1 shows a dot instead of a number).
3 Comments
MAKAIROSI  [author] 29 Feb, 2024 @ 3:39am 
Btw, to anyone reading this, I have added a guide on doing this directly with code, without using any plugins. You can find the guide as "single use items" or something.
MAKAIROSI  [author] 8 Sep, 2020 @ 7:01am 
@Greenspottedeer If you are ok with not having extra currencies displayed to the player, then yes, you can have any kind of shop you want, and any kind of availability you want.

What this does, in simple terms, is setting up an item to cost 1 of an extra currency stored in variable 1 (let's say), then hiding that currency. You can do whatever you want with that variable, or have the item cost multiple currencies to have it available in specific days, hours, and stock numbers by setting more variables.

Note that this is not a plugin, just a guide. So if it doesn't work with what you want, you can simply change it to allow for a different behaviour.
CaroShio0083 7 Sep, 2020 @ 4:04pm 
okay does that work with having hidden shop and black market goods? I am just wondering if unlimited shop should be able to have VIP, Black market goods, and special sale goods something developers never thought to put in game but variable would be one day of week.