Mods / C&N Trader

Tags:
Other
Author:
KenigVovan
Side:
Both
Created:
May 15th 2022 at 2:45 PM
Last modified:
2 days ago
Downloads:
11495
Recommended download (for Vintage Story 1.22.7):
cantrader_1.6.2.zip  1-click install

C&N TRADER

Custom traders with a living, supply-and-demand economy for Vintage Story

C&N Trader adds configurable trader NPCs with dynamic prices: buying raises a price, selling lowers it, and prices slowly return to their base. Build traders in an in-game admin panel (no JSON editing), save them as presets, and spawn them with a command.

Living Economy

Every buy/sell entry has its own pricing strategy that decides how the price reacts to trades and to the passage of time. Prices are always clamped between a configurable floor and ceiling (min × basemax × base).

= None

Fixed price. Trades and time never move it - a classic static shop.

L Linear

Each traded batch moves the price by a fixed fraction of the base price, and the price drifts straight back toward base at a set rate per day.

E Elastic

Multiplicative: each batch scales the current price by (1 ± k), so swings are proportional to the price and recovery toward base is a smooth exponential.

S Stock

The price follows the remaining stock. Full stock sits at base; scarcity drives a sell price up toward the ceiling, while a glut drives a buyback price down toward the floor.

T Step

A staircase: every N units traded, the price jumps by a fixed percentage in that direction, then steps back toward base over time.

Settings cascade: each item inherits from the preset default, which inherits from the global config - you only override what you need.

Price trend at a glance: in the trade window each offer whose price has drifted from its base shows a colored arrow and percentage (▲ green = a good deal for you, ▼ red = a bad one), so players can spot bargains and gluts without doing the maths.

Restock over time: stock isn’t just reshuffled - each entry slowly refills toward its ceiling at a per-item rate (restock quantity every restock hourDelay hours), so a sold-out item recovers gradually instead of snapping back full.

Shared quotas (goods groups): tag several entries with the same goods group and one goods group max and they draw from a single shared stock pool - handy for “this trader only has 20 tools total, in any mix”.

Presets & Personalities

  • Reusable presets: a whole trader — display name, starting money, buy list, sell list and all supply/demand defaults - saved to a file and spawnable by name.
  • Buy & sell lists: per-item price (average + variance), stock (average + variance), stack size, restock timing and per-item pricing strategy.
  • Personalities: pick a haggling personality per trader, or let it roll at random on spawn.
  • Periodic refresh: traders reshuffle their stock and money on a configurable interval.

Currency

A configurable currency table maps items to monetary value, so traders price and pay out in the money items you define — and it resyncs to every connected player when the config is reloaded.

  • Works standalone: out of the box the currency is a single value-1 coin (game:gear-rusty), so the mod needs no economy dependency. Swap in your own coin set (e.g. copper/silver/gold tiers) in the config.
  • Named currency profiles: define several coin sets and let each trader trade in a different one - pick a profile from a dropdown in the preset editor (or set currencyProfile in a tradelist). Traders with no profile use the global table, so old setups are unaffected.
  • Attribute-aware coins: the same item can count as different values depending on its stack attributes, so one “coin” item can carry several denominations.
  • Real change: overpayments are paid back in the largest denominations that fit, and the trader stores its takings in the profile’s base coin.

Setting up currency

Step 1 - define the coins in-game (no file editing). Open the admin panel (Ctrl + Shift + V) and go to the Currency tab. Pick the default profile (the global money) or create a named one, then add coin rows - each is an item code, a value and optional attributes - and hit Save. It’s written to the config and synced to every player instantly. Always include a value-1 coin.

Step 2 - assign a currency to a trader. On the Presets tab, edit a preset and pick a profile from the Currency dropdown (it lists default plus every profile you made). default means the global CURRENCIES table, so traders left on it are unchanged.

Prefer files? Everything above is just the config at ModConfig/cantrader.json. The global money set is CURRENCIES - each entry is a coin item Code and its unit Value:

"CURRENCIES": [
  { "Value": 10000, "Code": "canmarket:cangearpayment-gold" },
  { "Value": 100,   "Code": "canmarket:cangearpayment-silver" },
  { "Value": 1,     "Code": "canmarket:cangearpayment-copper" }
]

Always include a Value: 1 coin — the trader stores its takings in it and needs it to make exact change.

Per-trader currencies are named sets under CURRENCY_PROFILES; each is a coin list just like CURRENCIES. The name is what appears in the preset’s Currency dropdown:

"CURRENCY_PROFILES": {
  "shells": [
    { "Value": 20, "Code": "game:seashell-pink" },
    { "Value": 1,  "Code": "game:seashell-white" }
  ]
}

Attribute-aware coins: add Attributes to make one item count at several values by its stack attributes (compared as text, most-specific first):

{ "Value": 50, "Code": "game:gear-rusty", "Attributes": { "quality": "5" } },
{ "Value": 1,  "Code": "game:gear-rusty" }

After hand-editing the file, run /ven reload to re-read the config and resync every player — no restart needed. (Saving from the Currency tab does this for you.) A coin whose item code doesn’t exist is skipped with a log warning.

Admin Tools

Open the admin panel with Ctrl + Shift + V or the .vengui command (needs the controlserver privilege). It has three tabs: a Monitor of every loaded trader (teleport to / remove, place a preset where you look), the preset editor, and a Currency editor for the coin tables.

  • In-game preset editor: a full GUI panel to build and tune traders, item lists and supply/demand behaviour — add items straight from your hand, no config files to hand-edit.
  • Live monitor: a sortable list of all loaded traders with their position, preset, current money and one-click teleport / removal, refreshed automatically.
  • Strategy badges: the item list shows a compact colored tag (= / L / E / S / T, or a dim · for inherited) so you can read a trader's whole pricing setup at a glance.
  • Commands (require the controlserver privilege):
    • /ven new — spawn a trader at your position
    • /ven place <preset> — spawn a named preset where you look
    • /ven del — remove the trader you are looking at
    • /ven info / /ven listall — inspect loaded traders
    • /ven sh — reshuffle a trader's stock
    • /ven presets — list available presets
    • /ven reload — reload config from disk and resync to players

In-Game Guide

Open the handbook (H) and look under Guides for “C&N Trader: Supply & Demand Pricing” — an in-game explanation of every strategy, the inheritance layers and how to read the item list.

Configuration

Global defaults live in an editable JSON config at ModConfig/cantrader.json. Key fields:

  • ENABLE_SUPPLY_DEMAND — master switch for living prices & restock.
  • SD_DEFAULT_STRATEGY and SD_DEFAULT_PER_PURCHASE / _PER_DAY / _MIN_FACTOR / _MAX_FACTOR / _UNITS_PER_STEP / _STEP_PCT — the bottom of the inheritance chain, used whenever an item and its preset both leave a setting blank.
  • CURRENCIES and CURRENCY_PROFILES — the coin tables described above.
  • WRITE_LOG / LOG_FILE_PATH / LOG_FILE_BUYING_PATH — optional file logging of every trade (one line per player/item: player#item#count#unixtime), flushed on a timer for later analysis.

Presets are stored separately in ModConfig/CANTrader/presets (one file per preset), and hand-editable vanilla-style trade lists in ModConfig/CANTrader/tradelists — both seeded on first launch, so shipped defaults stay untouched. Run /ven reload to re-read the config, presets and currency tables from disk and resync to players without a restart.

Mod Version Mod IdentifierFor Game version Downloads Released Changelog Download 1-click mod install*
1.6.2 cantrader 13 2 days ago cantrader_1.6.2.zip 1-click install
  • ApplyCurrencyAttributes fix
1.6.1 cantrader 18 3 days ago cantrader_1.6.1.zip 1-click install
  • crash fixes
1.6.0 cantrader 1703 Jul 11th at 1:52 PM cantrader_1.6.0.zip 1-click install
  • price strategies and gui for settings
1.5.1 cantrader 95 Sep 14th 2025 at 8:23 AM cantrader_1.5.1.zip 1-click install
  • init config
1.5.0 cantrader 37 Sep 12th 2025 at 7:26 PM Empty cantrader_1.5.0.zip 1-click install
1.4.0 vendor 329 Jan 21st 2024 at 9:33 AM Empty vendor_1.4.0.zip 1-click install
1.3.4 vendor
1.18.5 - 1.18.6-rc.1
355 Jun 19th 2023 at 4:08 PM vendor_v1.3.4.zip 1-click install

- hats, gems

1.3.3 vendor 325 Jun 4th 2023 at 10:50 AM Empty vendor_v1.3.3.zip 1-click install
1.3.2 vendor 319 May 13th 2023 at 8:32 AM Empty vendor_v1.3.2.zip 1-click install
1.3.1 vendor 344 May 11th 2023 at 4:53 PM vendor_v1.3.1.zip 1-click install

 - got ai tasks from new trader and gui dialogs

1.3.0 vendor 337 May 6th 2023 at 6:02 PM Empty vendor_v1.3.0.zip 1-click install
1.2.16 vendor 366 Apr 2nd 2023 at 2:42 PM Empty vendor_v1.2.16.zip 1-click install
1.2.15 vendor 328 Apr 2nd 2023 at 2:04 PM Empty vendor_v1.2.15.zip 1-click install
1.2.14 vendor 435 Jan 24th 2023 at 4:47 PM vendor_v1.2.14.zip 1-click install

- groups of goods; max for group

1.2.13 vendor 394 Dec 23rd 2022 at 4:33 PM Empty vendor_v1.2.13.zip 1-click install
1.2.12 vendor 360 Dec 15th 2022 at 1:48 PM vendor_v1.2.12.zip 1-click install

- fix trader staytime again

1.2.11 vendor 375 Dec 10th 2022 at 10:01 AM Empty vendor_v1.2.11.zip 1-click install
1.2.10 vendor 363 Dec 9th 2022 at 7:28 PM vendor_v1.2.10.zip 1-click install

- here we go again

1.2.9 vendor 351 Dec 9th 2022 at 5:38 PM vendor_v1.2.9.zip 1-click install

- infinite stayed vendor fix

1.2.8 vendor 373 Nov 17th 2022 at 10:17 AM vendor_v1.2.8.zip 1-click install

- crash fix

1.2.7 vendor 376 Nov 13th 2022 at 1:48 PM Empty vendor_v1.2.7.zip 1-click install
1.2.6 vendor 376 Oct 20th 2022 at 4:51 PM Empty vendor_v1.2.6.zip 1-click install
1.2.5 vendor 363 Oct 2nd 2022 at 8:54 AM Empty vendor_v1.2.5.zip 1-click install
1.2.4 vendor 368 Sep 26th 2022 at 7:14 AM Empty vendor_v1.2.4.zip 1-click install
1.2.3 vendor 369 Sep 25th 2022 at 11:44 AM Empty vendor_v1.2.3.zip 1-click install
1.2.2 vendor 383 Sep 24th 2022 at 10:56 PM Empty vendor_v1.2.2.zip 1-click install
1.2.0 vendor 365 Sep 23rd 2022 at 6:00 PM vendor_v1.2.0.zip 1-click install

- jump to 1.17.4

1.0.3 vendor 387 Jul 3rd 2022 at 12:04 PM vendor_v1.0.3.zip 1-click install

 - names of items from lang; liquid items in buying list

1.0.2 vendor 409 May 22nd 2022 at 3:03 PM vendor_v1.0.2.zip 1-click install
  • now you can set blocks in list of objects vendor buys (there is also possibility to add attribute which should object to have - more info in desc)
1.0.1 vendor 437 May 21st 2022 at 7:14 PM vendor_v1.0.1.zip 1-click install

- vendor saved categories were not load properly after restart

1.0.0 vendor 427 May 15th 2022 at 2:48 PM Empty vendor_v1.0.0.zip 1-click install

9 Comments (oldest first | newest first) (threaded | flat)

Ragin_The_Cajun, 5 days ago

Hey Kenig, having an issue where if a bucket is in a traders inventory, it will crash you when you attempt to open their trade window. Heres the crash report.

Crash Report
System.Exception: Error while rendering item in slot vendor.src.CANTrader.CANItemSlotTrade (1x Block Id 16923, Code game:woodbucket)
Crash Report
System.Exception: Error while rendering item in slot vendor.src.CANTrader.CANItemSlotTrade (1x Block Id 16923, Code game:woodbucket)
Origin_Alpha_43, Sep 15th 2025 at 10:25 PM (modified Sep 16th 2025 at 12:13 AM)

commands didnt seem to work
i'll try updating to 1.5.1 to see if it'll work

edit: still gives errors, but kinda works

KenigVovan , Nov 17th 2022 at 7:59 PM

Runehawk
this traders won't be spawn by default, you would need to place them with "/ven new" and remove "/ven del".
On the server we have one trader which stays at the spawn and one which visits cities(using other mods; vanilla traders + caravans are deleted), so idk if you would need them.
But if you still want, you can change items he buys/sells in "assets\vendor\entities\humanoid\cantrader.json"

RuneScholar, Nov 17th 2022 at 11:43 AM

I know this is intended for a server but would it work ok in a single player game/lan game with friends?

KenigVovan , Jul 10th 2022 at 12:33 PM

@Vronizos,  for 1.17 i'll add new version which copy vanila trader entity(with it's gui, texture, shape) but it will use coins from tradeomat. Trades will be set through enity's .json file, not with config file.

Vronizos, Jul 10th 2022 at 12:15 PM

i have some issue with start this mod:


System.NullReferenceException: Object reference not set to an instance of an object

in vendor.src.vendor.Dispose()
in Vintagestory.Common.ModLoader.Dispose()
in Vintagestory.Server.ServerMain.EnterRunPhase(EnumServerRunPhase runPhase)
in Vintagestory.Server.ServerMain.Stop(String reason)
in _7zNxEbLnuy6Bq08TdMSIu9ZbrKf._ZHhrbmNLuSrtHTKBjZE8YscjKrG()
in System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
in System.Threading.ThreadHelper.ThreadStart()

KenigVovan , May 22nd 2022 at 4:45 PM

@Kara, through the config file you can set categories and items/blocks vendor will buy. There is already list of default trades which you can use as example. But "maxAmount" of object vendor will buy is not depends on players and if 1st player sell to 0 others won't be able to sell anything before categories will be updated.
Time delta in which vendor update it's categories and "maxAmount" is also can be set in config and is 1 day by default.

Kara, May 18th 2022 at 3:08 AM

if this is going to be a NPC that admins can configure.... this this will be amazing, for quests!!. <3