Inventory Engine

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 the package Third Party Support/Inventory Engine Support. This will unpack files into the folder 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. Add a Dialogue Manager GameObject.
  2. Add an Inventory Engine Lua component to the Dialogue Manager.
  3. 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.
  4. If you want to include an inventory in persistent data that's put in saved games and carried across scene changes, add a Persistent Inventory component to it.
  5. To control inventory in conversations, you'll use the Inventory Engine Lua Functions that the Inventory Engine Lua component made available.
  6. If you're using More Mountains' Corgi Platformer Engine, see Corgi Engine.

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 Lua Trigger.

Lua Function Description
mmAddItem(inventoryName, itemName, quantity) Adds a quantity of an item to an inventory.
mmRemoveItem(inventoryName, itemName, quantity) Removes a quantity of an item from an inventory.
mmGetQuantity(inventoryName, itemName) Returns the current quantity of an item in an inventory.
mmUseItem(inventoryName, itemName) Uses an item in an inventory.
mmDropItem(inventoryName, itemName) Drops an item from an inventory.
mmEquipItem(inventoryName, itemName) Equips an item in an inventory.
mmUnEquipItem(inventoryName, itemName) Unequips an item. Note the capitalization of this function!
mmEmptyInventory(inventoryName) Empties an inventory.

Notes:

  • inventoryName is the name of a GameObject with an Inventory component, such as "RogueMainInventory".
  • itemName 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)

<< Third Party Support