Shops with stocks ("cheating" way to do it)

So yeah, I came upon many threads asking for this, and I also wanted to implement this in my game. Since there is no actual plugin that does this reliably (and without bugs), I decided to come up with an idea myself: By utilizing Yanfly's "More Currencies" plugin.

That plugin basically allows you to have more currencies than gold, stored inside game variables. The item can be tagged that it costs not only gold, but also a variable. If the variable is lower than the item's cost, then the item is supposedly disabled in the buy menu.

So that's where I got the idea. You name a variable <<Stock_itemId>> (or item name, it doesn't matter, it's only for you to see). If you read the help file, putting the variable's name in <<>> makes its name hidden.

Then you tag the item that it also costs this variable and you set the cost to 1. So now it costs whatever gold it did, but also 1 "<<Stock_itemId>>".

In the beginning of your game, you can set the variable to whatever you want the stock to be. You can also change it, reset it, do whatever you want.

Unfortunately, the item's price will show a "1" and you will see the max stock next to your gold. To remove that you can set the font size to 1 - it will show a dot. Or you can edit the code and set it to 0 (instead of getting it from the parameters) to completely remove it.

Now, you can set the stock of any item in the game.

It's working perfectly so far for me!

PS:

If you set the font too low (or, by code editting, 0), you can't see any other currencies you are implementing in your game - although they will still work. I could edit the code further to allow for variables to be used as stock variables, but i'm not sure Yanfly allows such edits. Also, object variables are sadly not allowed, so you will need a new variable for an individual item, or place and item, or whatever.

PS2:

Sadly, i haven't found any means of contacting Yanfly to ask him about code edits. However, he does state that "Redistribution of the plugins and its code, outside the scope of game projects, is strictly forbidden[...]" so i am guessing editting his code in my own game (and that, i guess, goes for each one of us also) is fine, as long as it remains in our own game. Again, i'm only guessing.

This means i can't distribute my edits, but there certainly is a way to edit the code to allow completely hidden variables (along with the "currencies" variables) and, therefore, stocks in shops. EDIT: You can also separate invisible "stock" variables from visible variables to allow for currency variables AND stock variables!!

Original thread: https://forums.rpgmakerweb.com/threads/shops-with-stocks-cheating-way-to-do-it.116389/