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
210
Reaction score
98
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
218
Reaction score
195
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
210
Reaction score
98
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

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,798
Reaction score
14,018
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
3,184
Reaction score
1,185
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
8,029
Reaction score
5,332
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.

Latest Threads

Latest Profile Posts

Friendly reminder that you don't have to be able to do absolutely everything. It's okay to scale back features or assets if things are too much - especially if you're the only one working on the game! And you can always add things in later. <3
My new cutscene system makes it so much easier to add parallel stuff happening in the background, I can easily fill the whole screen with action.

I remember once when I was at Disney's Animal Kingdom and I got to dance with some of the cast members! It was so much fun! After the show my dad and I got frozen lemonade and some ice cream. It makes me feel better remembering the good things about my dad... maybe I will return to Orlando.
spending almost entire day to mod skyrim but it still couldn't run properly :(
My friend has become one with the glitter. @ImaginaryVillain, got any room in the Cult of the Sporkle?

Forum statistics

Threads
107,722
Messages
1,031,657
Members
139,859
Latest member
Jamie25
Top