Inventory Engine Support

This page describes how to set up the Dialogue System with More Mountains' Inventory Engine. (Inventory Engine is required.)

Inventory Engine copyright © More Mountains.

Inventory Engine Support Setup

Import these two packages:

  • Assets ► Plugins ► Pixel Crushers ► Common ► Third Party Support ► Inventory Engine Support
  • Assets ► Plugins ► Pixel Crushers ► Dialogue System ► Third Party Support ► Inventory Engine Support

This will unpack files into these folder:

  • Assets ► Pixel Crushers ► Common ► Third Party Support ► Inventory Engine Support
  • Assets ► Pixel Crushers ► Dialogue System ► Third Party Support ► Inventory Engine Support

This package adds Lua functions to control inventory in conversations and quests.

How To Set Up Scenes

Use these steps to set up an Inventory Engine scene for the Dialogue System:

  1. Set up Inventory Engine. The easiest way to do this is to drag and drop the Inventory and InventoryCanvas elements from Inventory Engine's PixelRogueRoom1 demo scene. This keeps all the references set up correctly.
  2. Add a Dialogue Manager GameObject.
  3. Add an Inventory Engine Lua component to the Dialogue Manager.
  4. If you want to automatically update the quest tracker HUD or invoke some other actions when an inventory changes, add a Dialogue System Inventory Event Listener component to it, and tick Update Quest Tracker.
    • Inventory Engine disables UI navigation while the inventory is closed. This component adds two helper methods that you can call in scripts or assign to UnityEvents such as the OnConversationStart() event in a Dialogue System Events component on the player GameObject, or the free Dialogue System Menu Framework's OnPause and OnUnpause events:
      • SetEventSystemNavigationEvents: Enables Unity UI navigation.
      • SetInventoryInputManager: Enables/disables inventory input (e.g., open/close inventory).
  5. If you want to include an inventory in saved games and carried across scene changes using the Pixel Crushers Save System, add an Inventory Engine Saver component to it.
  6. To control inventory in conversations, you'll use the Inventory Engine Lua Functions that the Inventory Engine Lua component made available.
  7. If you're using More Mountains' Corgi Platformer Engine, see Corgi Engine Support.

Inventory Engine Integration Example Scene

In the Inventory Engine example scene, an NPC offers a quest: If you bring him 6 apples, he'll give you blue armor. The conversation uses Inventory Engine Lua Functions.

The quest itself also uses the mmGetQuantity() Lua function in its quest tracker text.

The player's inventory (RogueMainInventory) also has a Dialogue System Inventory Event Listener component that updates the quest tracker HUD whenever the player's inventory changes.

The example scene uses the default generic dialogue UI and quest tracker HUD, which you can swap out with more visually-appropriate UIs in your own scenes.

Inventory Engine Lua Functions

You can use these functions in any Lua fields, such as dialogue entries' Conditions and Script fields and Dialogue System Trigger.

In the '...' Lua wizard dropdowns, these functions are available in Custom > IE.

Lua Function Description
mmAddItem(inventoryName, itemID, quantity) Adds a quantity of an item to an inventory.
mmRemoveItem(inventoryName, itemID, quantity) Removes a quantity of an item from an inventory.
mmGetQuantity(inventoryName, itemID) Returns the current quantity of an item in an inventory.
mmUseItem(inventoryName, itemID) Uses an item in an inventory.
mmDropItem(inventoryName, itemID) Drops an item from an inventory.
mmEquipItem(inventoryName, itemID) Equips an item in an inventory.
mmUnEquipItem(inventoryName, itemID) Unequips an item. Note the capitalization of this function!
mmEmptyInventory(inventoryName) Empties an inventory.
mmGetNumFreeSlots(inventoryName) Returns the number of free slots in an inventory.
mmGetNumFilledSlots(inventoryName) Returns the number of filled slots in an inventory.
mmResizeSlots(inventoryName, columns, rows) Resizes an inventory to columns x rows.

Notes:

  • inventoryName is the name of a GameObject with an Inventory component, such as "RogueMainInventory".
  • itemID is the name of an item in a Resources folder or AssetBundle. You can optionally omit the folder name "Items/" if your items are in a folder with this name.

Example:

mmAddItem("RogueMainInventory", "ArmorBlue", 1);
mmRemoveItem("RogueMainInventory", "Apple", 6)

Localization

To localize Inventory Engine's inventory details text:

  1. Replace the InventoryDetails script (on the InventoryCanvasGroup / InventoryDetails GameObject) with LocalizeInventoryDetails.
  2. Add any text that you want to localize, such as item names and descriptions, to the text table assigned to the Dialogue Manager.
    • The field name in the text table should be the item's actual description or name, such as "Apple".
    • If your default language is English, set the default translation to "Apple" and, for example, the "ru" (Russian) translation to "яблоко".
    • Remember to assign your text table to the Dialogue Manager GameObject's Localization Settings > Text Table field.

Saving & Loading

Inventory Engine has a SaveLoadManager. To tie the Dialogue System in, inspect (or add) a Dialogue System Inventory Event Listener component to the scene, and tick Handle MM Save Load Events. If you're using Corgi Engine and have added a Dialogue System Corgi Event Listener, only tick the checkbox on one of the components.

If you want to go the other way, and save an Inventory Engine inventory to the Dialogue System's save system, add an Inventory Engine Saver component to it.


<< Third Party Integration