RMMV (MV) Trying to open Shops with dynamic inventory. Help needed in placing items into shops through scripting.

Status
Not open for further replies.

TheTitan99

Veteran
Veteran
Joined
Nov 2, 2015
Messages
189
Reaction score
87
First Language
English
Primarily Uses
RMMV
Basically, I want to make a shop that updates its inventory based on variables. Like, as an example, if you are level 1, it has potions. If you're level 2, super potions. Level 3, ultra potions. I would rather not have a million different event commands where I have to manually place all the items in the shop, but instead simply have a simple array of items that I can create, and put that array into the shop.

It feels like it should be simply to do this. I know how to open a shop using script calls. The problem comes to actually giving that shop any inventory. For instance, this code:

Code:
var goods = [0,1,2,3];

SceneManager.push(Scene_Shop);
SceneManager.prepareNextScene(goods, false);
Doesn't work! The shop opens fine, and you can sell to your heart's content. But the shop has no items at all.

I tried changing it to this, but to no avail:

Code:
var goods = [$dataArmors[2], $dataArmors[3]];

SceneManager.push(Scene_Shop);
SceneManager.prepareNextScene(goods, false);
Once again, there's simply nothing in the shop.

I don't know how to proceed. Any help in formatting how to put items into the store's goods will be super helpful. Once I know the formatting, I think I can do the rest on my own. I just need to know how to, through scripts (or a plugin command), and not events, to populate a shop's inventory.
 

BurningOrca

Veteran
Veteran
Joined
Apr 14, 2019
Messages
214
Reaction score
187
First Language
German
Primarily Uses
RMMV
goods is an array of arrays, where each element has a different meaning:
- The first element of the subarrays is the kind (0 for item, 1 for weapon, 2 for armor)
- The second element is id of the item
- The third element is a flag to indicate whether a custom price should be set
- The last element is the custom price,

so:

Code:
var goods = [];

goods.push([0, 1, 0, 0]); // Would push item #1 without a custom price into the goods.
goods.push([1, 2, 1, 50]); // Would push weapon #2 with a custom price of 50 into the goods.

SceneManager.push(Scene_Shop);
SceneManager.prepareNextScene(goods, false);
I hope that helps you.
 

TheTitan99

Veteran
Veteran
Joined
Nov 2, 2015
Messages
189
Reaction score
87
First Language
English
Primarily Uses
RMMV
Thank you very much! This is super helpful, and I think I'll be able to make my systems now.

I think this can probably be closed now. Thanks a bunch!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Just report your first post and let the mods know you got your answer, if you want the thread to be closed.
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,895
Reaction score
1,029
First Language
Dutch
Primarily Uses
RMMV
hime or yanfly had a plugin to hide good until require level or whenever you want
unhide it if it makes easier for you.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,842
Reaction score
5,224
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top