Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

data/trade_tables/

A trade table: what a vendor sells and buys, at what price, with shared or per-player stock, and offers that rotate from a loot table. A vendor is a counter entity with the manifold-ai:vendor component, (table: "<key>", requires_attendant: true), whose slot.vendor slot its shopkeeper occupies. Prices are worked out on the server and items move all or nothing. Loaded by the server only.

Registrymanifold-ai:trade-table
Filesdata/trade_tables/*.ron, *.update.ron, *.final.ron
Sidesserver: only the server loads it
Readsnothing
ContractPopulation, data stage

Entry

A record, written TradeTable(..); the name before the parentheses is optional.

FieldTypeRequiredDefaultDescription
idstringyesThe table’s key, <mod-id>:<name>.
currencystring or NonenononeThe item kind (manifold:item-kind key) Coins(n) prices pay in. An unknown key fails the data stage (DATA010).
offerslist of OfferyesThe offers, 1 to 64.

Example

No bundled file declares one yet. From the reference’s test fixture, crates/manifold-server-state/tests/data-reference-fixture/data/trade_tables/bakery.ron, which the data stage loads in its tests:

TradeTable(
    id: "dataref-fixture:trade/bakery",
    offers: [(sells: Item(kind: "dataref-fixture:bread"), price: Item(kind: "dataref-fixture:coin"))],
)

Types

Offer

One offer: exactly one of sells and buys.

A record: Offer(..) or (..).

FieldTypeRequiredDefaultDescription
sellsGoods or NonenononeWhat the vendor sells for the price.
buysTradeItem or NonenononeThe item the vendor buys, paying the price.
pricetrade-priceyesWhat the buyer pays (or, on a buys offer, is paid).
stockStocknoUnlimitedHow its stock works.
rotationRotation or NonenononeFor a FromLoot offer, which needs one: how many picks it shows and how often they are rolled again.
tagstring or NonenononeA label for content ("price_floor").
requirescondition or NonenoalwaysA condition in the trade context (This the buyer, Target the counter) that must hold.

Goods

What a sell offer gives.

VariantWrittenDescription
ItemItem(kind: .., count: .., patch: ..)An item; also written Item("<item kind>").
FromLootFromLoot(string)The rotation’s picks from a loot table (manifold:loot-table key): the first stack of each roll. An unknown key fails the data stage (DATA010).

Item fields:

FieldTypeRequiredDefaultDescription
kindstringyesThe item kind (manifold:item-kind key). An unknown key fails the data stage (DATA010).
countitem-countno1How many.
patchmap of string to component-valuenononeComponent values for the item, by component key.

TradeItem

An item in an offer, written Item(kind: .., count: .., patch: ..) or Item("<item kind>").

A record: TradeItem(..) or (..).

FieldTypeRequiredDefaultDescription
kindstringyesThe item kind (manifold:item-kind key). An unknown key fails the data stage (DATA010).
countitem-countno1How many.
patchmap of string to component-valuenononeComponent values for the item, by component key.

Stock

An offer’s stock.

VariantWrittenDescription
UnlimitedUnlimitedAlways available.
PerPlayerPerPlayer(limit: .., restock: ..)Each player may trade limit per window that starts at their first trade in it.
SharedShared(limit: .., restock: ..)The vendor holds limit per slot, refilled restock after the first sale from full.

PerPlayer fields:

FieldTypeRequiredDefaultDescription
limitu32yesTrades per window, at least 1.
restockdurationyesThe window.

Shared fields:

FieldTypeRequiredDefaultDescription
limitu32yesUnits held, at least 1.
restockdurationyesThe refill delay.

Rotation

A rotating offer’s picks.

A record: Rotation(..) or (..).

FieldTypeRequiredDefaultDescription
slotsu8yesHow many picks it shows, 1 to 8.
rerolldurationyesHow often they are rolled again.

Value forms used here: component-value, condition, duration, item-count, trade-price.