Skip to content

Merchants

The Inventory module comes with a built-in system that allows two Bags to trade their contents in exchange for a specified Currency.

Merchant

Merchant Component

To initiate a trade between two Bags, one of them (the merchant) must have a Merchant component attached along with a Bag component.

  • The Bag component provides the stock of items available.
  • The Merchant component determines the type of transactions made.

Merchant Component

Merchant Info

The Merchant Info section allows you to give the Merchant a name and a description. This is completely optional, but can be useful to display the type of trading made by a certain Merchant.

Example

For example, having a merchant called Herbologist already gives a clue of the type of Items this merchant trades with.

Configuration

  • Infinite Currency: If checked, the Merchant will have an infinite supply of currency to buy Items from the client (Player). Otherwise it will use the Bag's wealth.
  • Infinite Stock: If checked, the number of available Items will not decrease after the client (Player) purchases them. Otherwise, the available stock decreases with each purchase made.
  • Allow Buy Back: If checked, every Item sold by the client (Player) is automatically added to the Merchant's stock. Otherwise, any Item sold cannot be recovered.
  • Sell Niche Type: If checked, it allows you to restrict the type of Items this merchant is willing to buy from the client (using the Sell Type field). For example, if a Merchant only deals with Herbs, it will refuse to buy a Sword from the client.

The Buy Rate is the coefficient applied to the price of an Item when the client (Player) buys it from the Merchant. Its default value is 1, which indicates the Items have no discount. To provide a 10% discount on all Items, this field should be set to 0.9.

The Sell Rate is the coefficient applied to the price of an Item when the client (Player) sells it to the Merchant. In most games, the selling price of an Item is lower (commonly half the price) than its real one, which is why its default value is 0.5.

Prices

Let's say an Iron Sword has a price of 100 gold. With the default values, the client has to pay 100 gold (100 x 1) to buy it from the Merchant, but will only receive 50 gold (100 x 0.5) when selling it back.

The Bag field is a reference to the Bag component from where the Merchant takes its stock.

Reference a Bag

If your Bag is placed along another game object, you can change the value of this field from Self to Bag and manually reference the correct object.

Skin UI is the user interface skin used by this merchant.