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.

REQUEST: A script needed for inventory

Cait

Member

Needed: A script or common event
Similar to: Dragon Quest IV
You played these chapters, Ragnar, Alena, etc, at the beginning of each chapter, you started with a clean slate, but when you played the hero, in chapter V, when the player joined your party, all the stuff he/she had before is added to your inventory. I know I will likely need a way of memorizing what the player has, removing it at the end of the chapter and then, adding it when the players begin to gather together. But not entirely sure how that would be done, I believe a script, but I suppose that could be done by means a common event. I don't need it now, but I will when I get past chapter two of my game, right now, I'm still planning and doing the outline. If anyone can help me, I'm not really good at things like this. o.o Anyone up for a challenge? Of course, it might be the easiest thing and not a challenge at all.. I'll admit.
SCRIPTS being used:
KGC_MapLightening
KGC_CustomMenuCommand
KGC_TitleDirection
KGC_DayNight
KGC_LargeParty
KGC_Dash_8DirMove
KGC_MiniMap
KGC_CategorizeItem
KGC_CategorizeSkill
KGC_OnScreenStatus
 
This should do the trick. :)

[rgss] 
#==============================================================================
# [ Item Storage ]
# by Drago del Fato
# ----------------------------------------------------------------------------
# Installation:
# Place Above Main
#==============================================================================
 
class Game_Party
 
  alias new_initialize :initialize
 
  def initialize
    @item_storage = []
    new_initialize
  end
 
  # Store Items command
  def is_store_items(slot_number)
    while slot_number > @item_storage.size - 1
      @item_storage.push(nil)
    end
    return if slot_number < 0
   
    # Save items
    @item_storage[slot_number] = @items.clone
  end
 
  # Load Items Command
  def is_load_items(slot_number)
    return if slot_number > @item_storage.size - 1
    return if slot_number < 0
   
    # Load items
    # Loaded items will be added to the current items
    @item_storage[slot_number].each{|item_id, n|
      if item_id > 0
        @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
      end
    }
 
  end
 
end
 
class Interpreter
 
  # Use in event, just call script and write
  # save_items(slot number where your items will be saved)
  # load_items(slot number where you saved your items)
 
  def save_items(item_slot)
    $game_party.is_store_items(item_slot)
  end
 
  def load_items(item_slot)
    $game_party.is_load_items(item_slot)
  end
end
 
[/rgss]

To use this script in event just use Script command and write:

- To save all items you currently have in a slot of your choice (you can have infinite amount of slots, or better to say, as much slots as your computer memory allows it) write:
[rgss] 
 save_items(1) #1 - is the slot number of your choice, you can write 3,4, 0, 100, etc...
 
[/rgss]

- To load items from the slot and ADD them to current items list write:
[rgss] 
 load_items(1) #1 - is the slot number where you SAVED the items with save_items
 
[/rgss]

You can use as many slots as you want, in whatever order you want but it would be a nice to practice using them from index 0 and so on...
 

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