**This is an old revision of the document!**

Component: Trading

This component is provided by trading upgrades

Component name: trading.
Callbacks:

  • getTrades():table
    Returns a table of trades in range as userdata objects.

Trade Object

A trade object represents an available trade nearby.

  • isEnabled():boolean
    Returns whether the merchant currently wants to trade this.
  • trade():boolean, string
    Returns true when trade succeeds and nil, error when not.
  • getInput():table, table
    Returns the items the merchant wants for this trade.
  • getOutput():table
    Returns the item the merchant offers for this trade.
  • getSortIndex():number
    Returns a sort index of the merchant that provides this trade. Trades can be grouped by the merchant offering them using this sort index. The index is the sort order placement of a merchant in the list of available merchants offering trades within range. Because it is merely a sort index, it can change between calls to getTrades if merchants leave or enter the range, or any previous merchant stops offering any trades.