Fundamentals

An inventory at most needs a name. To add items call the AddItem function, giving the ItemData and the amount to add. This will automatically attempt to add the amount to any stack of the same item type. If there isn't a stack, or not enough room in the stack it will add the extra amount to a new stack, until there is none left to add. However, a new stack will not be made if there isn't enough room to add a stack. This can be bypassed by setting MaxStacks to 0 (meaning unlimited stacks), or increasing MaxStacks. Remove items using the RemoveItem function, with the item name and how much to remove. This will also remove any empty stacks made in the process. To get how much of an item is in an inventory, call the GetStock function with the name of the item.

Items can have a name, description, weight, price, icon, prefab, and max stack. The item prefab can be used to spawn an item into the world. This prefab should have a QI_Item script, or a class that inherits from QI_Item. QI_Item just stores the QI_ItemData that it represents, so technically QI_Item isn't needed, just recommended for easy access to the item data. The max stack variable of QI_ItemData is how many of this item can be in an item stack. Setting it to 0 means unlimited per stack (and therefore there will only be one stack of the item). Item databases can be used to store lists of QI_ItemData, and retrieve them by name with the GetItem function.

Crafting handlers at minimum need an inventory and a type. The type is either consecutive or simultaneous. Consecutive means that items will be crafted one at a time, in the order of when they were added to the crafting queue. Simultaneous means the crafting handler will start crafting all items in the queue when they are put in it. The inventory is used to put in items when they are done crafting. To craft an item, simply call the Craft function with a crafting recipe and how many of that recipe to craft. Keep in mind that this will craft all of the items at once. For example, if you call Craft with a sword recipe and say 5, it will craft 5 swords as if it is one. If you want each sword to have a separate queue, then use a for loop to call the Craft function. Also, keep in mind that if the crafting time on a recipe is set to 0, the items will be instantly crafted.

Crafting recipes take a name (which can be the item name, but doesn't need to be), a list of ingredients, a product, and a crafting time. Crafting ingredients and the product need the QI_ItemData of the item, and how many is required or produced. 0 crafting time means the items will be crafted immediately (provided it's at the front of the queue in a consecutive crafting handler). The crafting recipe database is the same as the item database, but for crafting recipes.

Vendors are part of a character that can buy/sell items. This could be the player, shopkeeper, or someone else in the world. Vendors require an inventory and currency. To make a transaction between two vendors, call the Transaction function with the buyer vendor, seller vendor, item to buy, currency to use, and amount to buy. Transaction automatically checks if the buyer can afford the item and if the seller has the item to sell. However, you can check this manually using CanBuy and CanSell. Use the AddCurrency/RemoveCurrency functions to add or remove currency from the vendor. Calling AddCurrency can add a currency stash, add a currency stash with an amount in it, or add an amount to an existing currency stash. RemoveCurrency can remove an amount of currency from the stash, or remove a currency stash.

Vendors have currency stashes to keep track of how much of each currency they have. Currencies can have a name, description, and icon.