public

Rpg Maker Developers Group

Simple enough for a child, powerful enough for a developer

2 Followers

Can Some one help me out? Making my own shop

BMM Archive · July 16, 2026

Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.

Original Source

  • Original title: Can Some one help me out? Making my own shop
  • Original author: DarknessFalls
  • Original date: July 15, 2013
  • Source thread: https://forums.rpgmakerweb.com/threads/can-some-one-help-me-out-making-my-own-shop.15371/
  • Source forum path: Game Development Engines > Ruby Game System (RGSS) Scripts > Learning Ruby and RGSSx

Summary

First, let me apologize for all the threads. I am not a novice programmer, nor new to ruby (I did rails, and I am a software developer by trade). With that said, I have never "scripted" before and I have never worked with RGSS, it does seem easy to pick up, how ever if that were the case I wouldn't be here asking for help. Let get on with it. I have attempted to create a shop, this shop is going to use a specific currency. I wanted to understand...

Archived First Post

First, let me apologize for all the threads. I am not a novice programmer, nor new to ruby (I did rails, and I am a software developer by trade). With that said, I have never "scripted" before and I have never worked with RGSS, it does seem easy to pick up, how ever if that were the case I wouldn't be here asking for help.

Let get on with it.

I have attempted to create a shop, this shop is going to use a specific currency. I wanted to understand the way the shop classes, scenes, windows and such worked so I attempted to go out and create my own. I am no where near it though. Thus I need your help.

Note: This script is based of, Tsukihime, http://dl.dropboxusercontent.com/u/23043573/RPG%20Maker/RMVXA%20Scripts/Shop_Manager.txt

Couple of issues:

  • put @inventory.inspect will give me [[#<ClassObject>, #<ClassObject>], [#<ClassObject>, #<ClassObject>]] instead of the items.
  • when calling the scene to init the shop, I get an error on make_item_list, stating that .each doesn't exist. essentially it cant walk through an empty array.
This script composes of a series of classes that extend the parent, thus to reduce the need to re-write everything, but also allowing me to over ride, or use specific parent methods, with out the harm to other scripts that alias such methods. I thought this was the best approach.
This script, for the time being, is called as such:

## Create your items$kc_shop.create_master_inventory(1, 1, 1, 10) #id (unique), #item_type, #item_id, #price$kc_shop.create_master_inventory(2, 1, 2, 10) #id (unique), #item_type, #item_id, #price ## Open the shop windowGS.call_shop(GS.setup($kc_shop.get_inv)) #call the shop while passing the master inventory list to the shop window. There are things that I am missing in the main script and some naming issues have arisen (such as how I name things, not compilation errors), I understand that. How ever The main issue I am trying to solve, aside from those out lined in the list above is why I am getting: undefined each for Nil:NilClass. 

Its obvious to me, The inventory list is not being passed to the window, yet I assumed I took care of that in the GS.call_shop() method.

Note: This script is documented, how ever not deeply, near the end there is no documentation. I have created my own object for dealing with items called: Game_Guild_ShopObject

module GS  def self.setup(goods, purchase_only = false)    shop = Game_Guild_Shop.new(goods, purchase_only)  end    def self.call_shop(shop)    SceneManager.call(Scene_Guild_Shop)    SceneManager.scene.prepare(shop)  endend #==============================================================================# ** DataManager#------------------------------------------------------------------------------#  Create a new object called $kc_shop.#==============================================================================class << DataManager    #--------------------------------------------------------------------------    # * Create Game Objects    #--------------------------------------------------------------------------    alias kalacious_guild_shop_game_objects create_game_objects    def create_game_objects      kalacious_guild_shop_game_objects      $kc_shop = Game_Guild_ShopSetup.new    endend #==============================================================================# ** Game_Guild_ShopSetup#------------------------------------------------------------------------------#  Helps to set up the core shop it's self.#==============================================================================class Game_Guild_ShopSetup     attr_accessor :inventory_list    #--------------------------------------------------------------------------  # * Set up an empty array of inventory items  #--------------------------------------------------------------------------    def initialize    @inventory_list = []  end   #--------------------------------------------------------------------------  # * Create a master inventory list.  #--------------------------------------------------------------------------    def create_master_inventory(id, item_type, item_id, item_price)    inventory = make_inventory(id, item_type, item_id, item_price)    @inventory_list.push(inventory)  end    #--------------------------------------------------------------------------  # * Retieve the object.  #--------------------------------------------------------------------------  def get_inv    return @inventory_list  end    #--------------------------------------------------------------------------  # * Make the inventory.  #--------------------------------------------------------------------------  private  def make_inventory(id, item_type, item_id, item_price)    inventory = Game_Guild_ShopObject.new(id, item_type, item_id, item_price)    return inventory  endend  #==============================================================================# ** Game_Guild_ShopObject#------------------------------------------------------------------------------#  This class is a wrapper for how the shops object stores the data about#  the items in the shop.#==============================================================================class Game_Guild_ShopObject    attr_reader :id  attr_reader :item_type  attr_reader :item_id  attr_reader :item_price    #--------------------------------------------------------------------------  # * Set up the objects  #--------------------------------------------------------------------------  def intialize(id, item_type, item_id, item_price)    @id = id    @item_type = item_type    @item_id = item_id    @item_price = item_price  end    #--------------------------------------------------------------------------  # * Return the $data_item, $data_weapons or $data_armor based on the id and  #   the type.  #--------------------------------------------------------------------------    def guild_shop_item    return $data_items[@item_id] if @item_type == 0    return $data_weapons[@item_id] if @item_type == 1    return $data_armor[@item_id] if @item_type == 2  end    #--------------------------------------------------------------------------  # * Return the price.  #--------------------------------------------------------------------------  def get_guild_shop_price    return @price  endend #==============================================================================# ** Game_Game_Shop#------------------------------------------------------------------------------#  This class is responsible for dealing with the inventory of a guild shop.#  That is, we deal with the abillity to purchase only, the inventory, in #  regards to adding and deleting items and the abillity to, or the need for,#  the shop to be refreshed.#==============================================================================class Game_Guild_Shop    attr_reader urchase_only  attr_reader :inventory  attr_accessor :refresh    #--------------------------------------------------------------------------  # * Set up the core shop.  #--------------------------------------------------------------------------    def initialize(goods, purchase_only = false)    @purchase_only = purchase_only    @inventory = goods    @refresh = false  end    #--------------------------------------------------------------------------  # * Return the inventory.  #--------------------------------------------------------------------------    def get_guild_shop_inventory    return @inventory  end    #--------------------------------------------------------------------------  # * Add a new item.  #--------------------------------------------------------------------------    def add_item(item)    @inventory.push(item) unless @inventory.include? (item)  end    #--------------------------------------------------------------------------  # * Delete an item based on id.  #--------------------------------------------------------------------------    def delete_item(item_id)    @inventory.delete_at(item_id-1)  endend   class Window_Guild_Shop_Buy < Window_ShopBuy    def get_current_item    @inventory[item]  end    def make_item_list    @data = []    @items = {}    @price = {}    @inventory.each do |inventory|      item = inventory.item      @data.push(item)      @items[item] = inventory      @prive[item] = inventory.price    end  endend class Scene_Guild_Shop < Scene_Shop    def prepare(goods, purchase_only = false)    super    @inventory = goods    @purcahse_only = purchase_only  end    def create_buy_window    wy = @dummy_window.y    wh = @dummy_window.height    @buy_window = Window_Guild_Shop_Buy.new(0, wy, wh, @goods)    @buy_window.viewport = @viewport    @buy_window.help_window = @help_window    @buy_window.status_window = @status_window    @buy_window.hide    @buy_window.set_handlerok,     methodon_buy_ok))    @buy_window.set_handlercancel, methodon_buy_cancel))      end    end
Your help and patience are much appreciated. I believe I am some where close to being on the right tack. I did not use Tsukihime's script, when it might be apparent too because I did not want to risk using other shop scripts and them being affected, while I don't believe his would cause conflicts, the purpose of this was to learn on my own how to create objects, pass the around and create my own shop while using core resources.

Downloads / Referenced Files

Log in to download

Log in, then follow the RPG Maker Developers Group to see these download links.

Log in to download
Creator Claims / Removal

If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.

#039#id#item_type#item_id#price

Replies (0)

No replies yet.

0 replies 1 view

Log in to reply.

User Avatar