Extending Scene_Shop

I figured this out the hard way you cannot do:

class Scene_Guild_Shop < Scene_Schopendand then do:

SceneManager.call(Scene_Guild_Shop)And expect it to work - especially when your calling it as a script call, with out first passing items. to populate the window. I get the following error:

Which happens to be:

def make_item_list @data = [] @price = {} @shop_goods.each do |goods| ## throwing the error case goods[0] when 0; item = $data_items[goods[1]] when 1; item = $data_weapons[goods[1]] when 2; item = $data_armors[goods[1]] end if item @data.push(item) @price[item] = goods[2] == 0 ? item.price : goods[3] end end endAll because, I have not populate the list with items, weapons or armor. Now maybe I am in over my head with understanding the shop. but the goal here is to create my own shop while using many of the functions provided by the default shop. This shop could then be populated via script call and opened the same way.

So My question is:

How do you extend the scene_shop, keep much of the same functionality yet call the new shop via script call and populate via script call? I assume @shop_goods must have some kind of call I can do on it to say add item of type, with these id's at this cost per id?
Scene_shop needs a preparation statement before it can be called. As such, on top is a method called 'prepare', where you setup the items to be sold, and whether or not the shop can sell items only, they won't buy items off you. I'm not sure of the exact format of what @goods should look like, so just run the game with a console, add a 'put @goods' in the prepare statement, and look in a shop for what it looks like, and then you can use it in yours.
I did something better:

puts goods.inspect gave me:  [[0, 13, 0, 0, false], [1, 24, 0, 0]]

Which from my understanding is: [[item_type, Item_id, ?, ?, purchase_only], [item_type, item_id, ?, ?]]

Not really sure how I would set this up into a script call. This isn't really documented in the help file. Item type is either, 0, 1 or 2 (item, weapon or armor). It would have to be something that creates a 2 dimensional array of arrays.

This: [[0, 13, 0, 0, true], [1, 48, 0, 0], [1, 52, 0, 0], [0, 21, 0, 0]] is a set of two weapons, two items with purchase only set to true. I am looking at something like:

set_puchase_only_to_true?()

set_items()

set_weapons()

set_armor()

Which is all fine and dandy, the issue is, the first entry also has true/false in it to determine if the shop is purchase only or not. Got any ideas how I could set that part up? Would it be better to create one script call? create_shop() and populate a shop that way?

Note: I may be wrong on the two dimensional array thing it looks like one to me but as I read some stuff on multi-dimensional arrays in ruby it looks like a matrix - clarification please?
You could do what I did and just replace that ugly looking array in the first place like I did in my Shop Manager. I provide my own ShopGood object that holds all of the information required to populate your shop lists.


Since the ShopGood simply contains an RPG Object, I have much more flexibility over what I want to do with the stuff the shop is buying or selling.
your script has given me amazing ideas, thank you. close thread
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.

Original thread: https://forums.rpgmakerweb.com/threads/extending-scene_shop.15328/