Inventory Core

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

This plugin provides a standard way to manage inventories of items and gold.

It offers multiple inventories so that the party for example can have multiple inventories, which can be swapped depending on your needs.

A new “Inventory” object is available for plugin developers, which allows you to easily provide inventory support for any object that you like.

Additional inventory functionality will be added over-time as they are developed.

Download

Plugin: download here (right-click, save-as)

You will also need this bug fix: Orange Circular Json. Required to address a problem where you can’t save your game.

Related Plugins

  • Feldherren Inventory Value – calculates the total value (price) of all items in the inventory and stores them in variables.

Installation

Download ths plugin and place it in the “plugins” folder in your project’s “js” folder. Then open your Plugin Manager (F10), double-click an empty row, and select the HIME_InventoryCore plugin.

Once it is in your list of plugins, turn the plugin on.

Usage

Multiple Inventories

This plugin offers you the ability to manage multiple inventories.
The party, for example, can have multiple inventories.

To create an inventory, use the script call

$gameParty.createInventory( ID )

Where the ID is a name that you will use to reference the inventory throughout the game. For example, you can say things like

$gameParty.createInventory( "Main Inventory" )
$gameParty.createInventory( 1 )

To switch inventories, use the script call

$gameParty.switchInventory( ID )

Assuming the inventory is already created, the party will use the specified inventory as the default inventory. For example, assuming you have a second inventory called “sub”, you could switch to that inventory using

$gameParty.switchInventory( "sub" )

To merge inventories, use the script call

$gameParty.mergeInventory( ID1, ID2 )

This will merge inventory 1 into inventory 2, and delete inventory 1.
Inventory 2 will be set as the default inventory.

For Developers

The default inventory implementation for parties is no good. The inventory should be abstracted into its own class and an instance of it held by the party. The purpose of this plugin is to provide such an abstraction so that it is easier to work with inventories.

The two objects that you will be interested in are

  • Game_Inventory
  • Game_Inventories

The Game_Inventory object holds all of the usable items, weapons, armors, and gold. It has the same interface as the party; you can take a look at the methods provided.

The Game_Inventories object is a container that’s used to manage multiple inventories. Any object that can have support for multiple inventories should use this to work with individual inventory objects.

For backwards compatibility, all of the methods that were originally in Game_Party have been replaced with calls to its “current” inventory, which is defined to be the inventory that all items/gold will be sent to. The current inventory may be switched at anytime using script calls.

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

You may also like...

16 Responses

  1. Anonymous says:

    Are you going to make any add-ons to this plugin that can cause actors to have their own personal inventories?

  2. Anonymous says:

    Are there any compatibility problems with any of Yanfly’s plugins?

  3. Mega says:

    So I created an event at the beggining of the game to create a new inventory: $gameParty.createInventory( Dei ). And when I start the game and get to the part where it creates the inventory it says ReferenceError Dei is not Defined, I really dont know what I did wrong if someone has the solution to this it would really be appreciated.

  4. Rinku says:

    I’m getting this error:
    cannot read property “gainItem” of undefined

    I allow the player to Select Item (command) an item, lose that item and then switch to a new inventory. Then add back that same item to the new inventory (Thus the new one is a scenario where the player is limited in item usage).

    This works. However, after I merge the inventories (which works) and repeat the above process. It gives out the
    “cannot read property “gainItem” of undefined”
    Error for:
    $gameParty.gainItem($dataItems[$gameVariables.value(32)]
    , $gameVariables.value(37));

    • Rinku says:

      Ah, I figured it out.

      After merging the inventories, I didn’t realise it also deleted the old one. So when I repeat the “above” process it was attempting to switch to an inventory that was just deleted and adding items via gainItem was running into an error I assume.

      By re-creating the inventory right after merging the two, my problem has been resolved :3

      • Hime says:

        Yes, merging inventories will delete the old one. I will see if I can put some emphasis on that in the description.

  5. Schildfraggle says:

    Amazing plug-in, it’s really what i need in my game. I just have encountered a big problem. I don’t know if i am using it wrong, but when i try to use this plug-in (Inventory Core alone, or with the Multiple Inventory) i can’t save in-game. It doesn’t collide with other plug-ins because i tried to run it alone and it still doesn’t work.

    Maybe you have a suggestion for me, or maybe other people have the same problem.
    The plug-in works fine otherwise.

    • Hime says:

      There's another plugin in the download section that is required in order to save the game: Orange Circular JSON It is a critical bug that needs to be addressed.

      Well, until I figure out a way to avoid the problem.

  6. James Hyatt says:

    This looks like an amazing Plugin, but i have one question , would it be possible to use this to make a Grid based inventory and a bank/stash for a player to store extra items ? Kinda like the inventory’s in the Diablo games from Blizzard runs?

    • Hime says:

      I will be building some custom inventory scenes on top of this plugin. Thanks for the suggestions!

      For the bank/stash, I have an “item trading” scene in development, which you can use to trade between two inventories.
      The second inventory could be treated as a storage inventory.

  7. Feldherren says:

    My inventory value script is now up to date for your Inventory Core script, and even works better now – you can just get the value of the current inventory’s holdings, as well as the value of specific named inventories.

    https://github.com/Feldherren/mv-inventory-value

    Enjoy.

Leave a Reply

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax