Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

item storage box

How would I make it so that I can have just like a chest, like Resident Evil except it wouldn't need to link up with other chests though, just that room. The chest would be able to store gold and items, hopefully.
 

OS

Sponsor

uhhh...do mean with events? If so, this is the wrong section. Try RMXP General Help. If you want a script, please be a little more descriptive, becuase I am confused as hell. Do want a Chest, or a variable that holds item data (container)?

Peace out!

~Broken
 
I am uploading all my older scripts soon (for for me still saying that, just minor updating and such). I have this exact script.

Basically, all it entails is creating a Game_ItemBox class, then filling that box with counters and such. Nothing hard. If you want me to go into detail on the simple process, let me know.
 

OS

Sponsor

Now that I understand better, I think this might help. I'm righting a container script to become better at scripting. It allows you to make a Container (like a box, a berral, a chest, or whatever), and fill it with items, weapons, armours, and even gold. It comes with a Special Menu that allows the player to take items out, place items in, and trade items. I don't know much about Seph's script, but it's probably better than mine. If you want to see my Container Script, there should be a topic in this forum.

Peace out!
~Broken
 
Sephiroth if you could give me that script or tell me how it's done I could try to give it a shot. Akahi, I will take a look at your's and see if it looks like something I could use.
 

OS

Sponsor

Okay, sorry I haven't posted my script yet. It was really crappy (it came with a special menu, and special features, but I screwed it up beyond repair). So here is a basic Container script.

Code:
class Container
  def initialize(type, max)
    @type = type
    @max = max
    if @type == 0
      @items = []
    elsif @type == 1
      @gold = 0
    end
  end
  
  def place_gold(amount)
    a = amount + @gold
    if a <= @max
      @gold += amount
    end
  end
  
  def add_item(item_id)
    a = @items.length + 1
    if a <= @max
      @items.push(item_id)
    end
  end
  
  def take_gold(amount)
    if amount <= max
      @gold -= amount
      $game_party.gain_gold(amount)
    end
  end
  
  def take_item(item_id)
    for i in @items.size
      if @items[i] == item_id
        @items.delete_at(i)
        $game_party.gain_item(item_id, 1)
      end
    end
  end
end

To use it, just create a script or use Call Script and write this;
Code:
container = Container.new(type, max)

where container is the name of the container, type is 0 for Items, or 1 for Gold, and max is the largest amount of items or gold that will fit.

Code:
container.add_item(item_id)
container.place_gold(amount)

These will take from the Container and give them to the player!
Code:
container.take_item(item_id)
container.take_gold(amount)

I hope this works! Peace Out!

~Broken
 

OS

Sponsor

All you have to do is container_name.add_item(item_id) to add 1 item. If you want, I can make it so that you can input more? Nevermind, I did it anyways:

replace the original add_item(item_id) with this:
Code:
def add_items(item_array)
    a = @items.length + item_array.length
    if a <= @max
      for i in item_array.length
        b = @items.length
        if b <= @max
          @items.push(item_array[i])
        end
      end
    end
  end

To use it, use container_name.add_items([item_id]),
where item_id is any item id in the Database. To add more items, use this;
container_name.add_items([id1, id2, id3,...]) You can add as many items as you want so long as the amount is less than the max value of holdable items.

If you need any help, lemme know!
Peace Out!

~Broken
 

OS

Sponsor

The instructions are in my above post. But I'll try to explain better...

Create the Item Storage Event (a chest, NPC, etc...) and use a Call Script Command with the line of code: container = Container.new(type, max)
The parameters type and max are explained above. To add data, in a Call Script command, add container.add_item(item_id) or container.place_gold(amount).

To access this data, I suggest using this new bit of code:
Code:
class Container
  def initialize(type, max)
    @type = type
    @max = max
    if @type == 0
      @items = []
    elsif @type == 1
      @gold = 0
    end
  end
  
  def place_gold(amount)
    a = amount + @gold
    if a <= @max
      @gold += amount
    end
  end
  
  def add_item(item_array)
    a = @items.length + item_array.length
    if a <= @max
      for i in item_array.length
        b = @items.length
        if b <= @max
          @items.push(item_array[i])
        end
      end
    end
  end
  
  def take_gold(amount)
    if amount <= max
      @gold -= amount
      $game_party.gain_gold(amount)
    end
  end
  
  def take_item(item_id)
    for i in @items.size
      if @items[i] == item_id
        @items.delete_at(i)
        $game_party.gain_item(item_id, 1)
      end
    end
  end
  
  def get_contents
    return @items if @type == 0
    return @gold if @type == 1
    return nil
  end
end

Replace the original script with this one. In a Call Script command use a = container.get_contents. Then create a conditional branche that displays the items based on what is returned. You probably don't understand what I mean, but I don't have much time to explain. Sorry. Peace!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top