RGSS3 Adding multiple items to shop

Add multiple items to shop quickly.

Synopsis:

Adding multiple items to the shop processing at once.

There could already be a shop script out there that does this but i can't find it. So i came here for your aid

In case i'm not clear enough

Basically I want to add multiple items to one shop with only a few lines of code.

Adding items one by one can be time consuming and tedius.

Thanks in advance.
You can do it via a simple script call in an event:

goods = [2D array containing shop items]

SceneManager.call(Scene_Shop)

SceneManager.scene.prepare(goods, false (or true if you want the shop to be purchase-only))

 

goods must be a 2D array with the following format for each element array:

 

[0/1/2, itemID, priceoverride, overrideprice]

 

The first element is 0 if it's an item, 1 if a weapon, and 2 if an armor. item ID is the item's ID from the database. priceoverride will be 0 if you're using the item's database price, or 1 if you're setting a custom price. overrideprice is only relevant if priceoverride is 1, and its value determines how much the item will be sold for.

 

For example, if I wanted a shop that sold potions at a fixed price of 20G, an Iron Claw at standard price, and a Hard Leather at standard price, it would be

 

goods = [[0, 1, 1, 20], [1, 9, 0, 0], [2, 4, 0, 0]]
Well this seems a bit more tedius and time consuming than just simply adding the items in the window.

This answers my question, Thanks very much!
I dug up this scriptlet from an old game. Perhaps you might be interested in using it, or perhaps not. Just toss the scriptlet into a 'script' command within an event. Input whatever item, weapon or armor ids you want in the store within the ':data' array.

Code:
# Hash of Item IDsitems   = { :id => 0, :data => [1, 3, 5] }# Hash of Weapon IDsweapons = { :id => 1, :data => [5, 7] }# Hash of Armor IDsarmors  = { :id => 2, :data => [10] }goods = [][items, weapons, armors].each { |hsh|  hsh[:data].each { |item|    goods.push([hsh[:id], item, 0, 0])  }}SceneManager.call(Scene_Shop)# method | prepare(goods, buy_only)#  - goods : Array of store goods#  - buy_only : Boolean determining if store is 'buy only' (no selling)SceneManager.scene.prepare(goods, false)Fiber.yield 
There is no functionality to alter the price of each item in the scriptlet, so as long as you can live without that everything should be fine.
Thank you that scriptlet looks great!

I was planning on using the default prices anyway.

Original thread: https://forums.rpgmakerweb.com/threads/rgss3-adding-multiple-items-to-shop.40597/