Техническая документация доступна на английском языке. Имена кода и полей соответствуют текущему Mod API.
МОДИНГОВАЯ ДОКУМЕНТАЦИЯ
Settlements and trade
Click the settlement banner to name your town and see its population, arrivals and births, and recorded deaths. The overview, packing and trading belong to the base game. New towns start with a localized biome name and a short identifier. The save dialog uses the town name for its first manual save, then remembers the last save name you entered.
Native trading and campaign services
| Service | Where it works |
|---|---|
| Settlement Trading | Packing content, packed-goods-only trade, shared economy and sandbox trade |
| Campaign Trading | Unlocked campaign markets in the current profile |
| Settlement Map | Campaign cities, The Kingdom, recruitment and deliveries |
All three are native gameplay. No mod installation or activation is required. Old selections of their original pack IDs are ignored, while saved content, market, ledger and shortcut IDs remain unchanged. Other required mods still have to be present. Open and save a town to publish its identity and trading snapshot. Economy controls and the map shortcut are under Settings → Settlement Trading in both the launcher and pause menu.
The source study preserves the original parent-and-child mod design.
The Campaign Map extension adds location overviews and paid recruitment. Its trade link opens this screen with the selected campaign market already chosen.
Prepare an exporting town
- Build a warehouse packing table and manufacture goods using the Trade goods crafting category. Each crate consumes its listed contents, one wooden crate, one paper and one category dye.
- Click the banner and choose up to 15 distinct recurring crate products. Nothing is selected automatically.
- Save the town to publish its trading snapshot. Multiple saves share one identity, purse and quota.
- In another town, select Settlement trading in the merchant panel and choose that partner.
Recorded production
The export allowance is the actual number of trade crates completed in the most recent 12 local days. It is not extrapolated from growth, moisture, farms, mines, worker counts, minimum-stock targets or workstation capacity. Imported, reserved, purchased and development-spawned crates do not count as production. Packing output is saved with the town's history. Selecting a product cannot replenish its sold quota.
Inactive saved towns use their last published production as a finite allowance per network season. This is the existing abstract off-map economy: it does not run their citizens in the background. Live player sales always withdraw real physical inventory. To change an inactive town's production profile, play it, manufacture crates and save again.
The 63 initial products include protected fruits, nuts, grains, preserves, drinks, medicine, glassware, textiles, bricks, luxury furniture/decorations and an explicit starter-equipment list. Standardized stone spears, padding/leather armor, brown cloaks and scholar clothing pack in pairs. Bulk fruit/grain and bricks pack in twenties; drinks pack in twelves. These sizes fit the smallest ordinary worker inventory including packaging. Only registered packed trade goods can be bought or sold through settlement trading. Loose resources, individual tools, books, essences, necklaces and equipment are excluded. Equipment explicitly included in the packing catalog trades through its standardized crate. Dependent mods can add packed products through the same public registries.
The 2×1 packing table rotates. The non-rotating 2×2 marketplace pallet holds 20 crates in five layers of four, with each visible crate using its category strip and actual product badge. Unpacking returns the exact contents and one empty crate; paper and dye are consumed. Profession output and ingredient bonuses do not apply to pack/unpack transfers.
Snapshots update each game day, when export choices change and when saving. Keep a save of every town you want to trade with. Old saves without a settlement identity must be opened and saved with a compatible trading profile. Deleted or overwritten saves stop advertising that town.
Pack and unpack
Trade goods opens on Pack. Its Unpack tab lists the sealed goods the colony currently owns, including purchased deliveries at the banner and crates being hauled. Queue unpacking at a packing table to recover the listed contents and an empty crate. A missing table is explained in the row. Outstanding orders remain visible after stock runs out so their queues can be cancelled.
Trade crates already separate merchandise from usable loose items. Settlement Trading therefore hides manual reservations: stored crates can be sold directly or unpacked for use. On opening an older town, remaining reservations return to its banner with their item metadata and age intact. Durable receipts prevent duplicate returns when refreshing or restoring an earlier save.
This behavior is registered by the parent mod through
ModContext.registerManualTradeReservations(false). Existing mods that retain manual reservations
continue to use the shared reservation API and UI unless another enabled mod opts out.
Payment, travel and seasons
Gold changes hands when a transaction is accepted. Both purses are finite. Buying requires the player to afford the goods; selling requires the other town to afford them. Prices start with the resource registry's trade value. Crates cost the current value of their contents plus packaging, with one 15% markup. The base policy excludes artifacts and zero-value goods.
| Other town's biome | Delivery time |
|---|---|
| Meadows | 1 game day |
| Jungle, Mixed, Desert | 2 game days |
| Snow, Mountains | 3 game days |
Goods arrive at the settlement banner and must be hauled into storage before being sold again. The Shipments view lists incoming and outgoing cargo. Packed food has twice its normal shelf life; packing retains its existing freshness fraction. Escrow, travel and waiting for an inactive destination all age the cargo. Routes touching a desert use the shorter heated shelf life. Expired cargo arrives as spoiled food. Unpacking cannot reset freshness. Individual item metadata survives delivery.
The network advances with new days actually played in its towns, not wall-clock time. Every 12 network days, recurring quotas reset and stored towns receive random 250-2,500 gold grants. Switching towns contributes only newly played days. Reloading an older local day does not repeat a grant or rewind shipments. Income reaches an inactive saved town on its next load.
Campaign markets
The campaign extension replaces sandbox discovery with authored markets unlocked by completed stages in the same campaign profile. Sandbox towns and other profiles are excluded. C2 offers apple and pear crates; C5 offers coconut crates. Other markets need authored entries. When a corresponding saved campaign town exists, its recorded crate production, selected exports, purse and any not-yet-returned legacy cargo determine its supply. Otherwise the authored NPC market has its own seasonal crate catalog and starting purse. The current stage is not its own partner.
Saves and recovery
Identity, name, packing history and applied trade receipt positions are part of ordinary game saves.
Cross-town gold, reservations, sold quotas and shipments live in the user-data settlement-trading
directory, normally %LOCALAPPDATA%\ForgottenTowns\settlement-trading on Windows. Source checkouts
may use a configured user-data root.
Back up or move that directory with the saves. A save copy is the same town, not another market. Loading an earlier save replays unapplied receipts exactly once, including goods or gold it owes. If that save lacks resources it already spent through trading, trading pauses until they are available in storage or the purse. The rest of the town can continue running. Unreadable records fail closed: the game does not reset the ledger and grant replacement stock.
Legacy potential-output quotas are retained in the ledger for recovery but no longer advertised as new supply. Opening and saving the town publishes recorded production. Existing reservations, shipments, payments and selections remain recoverable. Legacy shipments did not record departure freshness; they retain the old arrival treatment and then age while waiting at their destination.
This version is local to the computer; it does not promise Steam Cloud synchronization or cross-computer trading. After moving user data, open and save each town at its new path to republish it.
Implement trading rules
The complete compilable examples are Settlement Trading and its Campaign extension. Both compile against only the public API JAR. The engine owns conservation, durable writes and the existing UI; mod code supplies pure policy callbacks.
| API | Purpose |
|---|---|
ModContext.registerSettlementTrading(rules) |
Register one policy for this pack |
supports(world) |
Select applicable worlds; the last applicable registration wins |
includesSavedTowns(world) |
Include sandbox saves or use authored partners only |
estimate(world, production) |
Select/cap recorded output with SettlementTrading.recordedExports(...) |
maximumExports(), configurableExports(world) |
Limit choices or supply fixed exports |
markets(world) |
Return currently unlocked authored markets |
price(...), accepts(...) |
Control prices and which goods towns buy |
travelDays(biome), seasonalGold(roll) |
Define delivery times and income |
ColonyContext.settlement(), production() |
Query detached town and production values |
ModContext.dataTable(id) |
Read deeply immutable captured JSON during registration |
Production contains packed sources with actual completed crate counts and available inventory.
Legacy fields for minimum stocks, free inputs and workers are empty/zero for compatibility.
Use SettlementTrading.recordedExports(production, maximum) in trade policies. The host caps every
policy result to actual recorded output, including older mods. Query daily rather than per frame.
Callbacks remain deterministic and free of filesystem/network side effects.
Authored tables
Declare tables in the manifest:
"tables": { "markets": "data/markets.json" }
The loader captures and hashes these files with the gameplay pack. At most 16 tables are allowed,
each at most one MiB. Paths stay inside the pack and outside its presentation-only about/ folder.
Read context.dataTable("markets") in register, then validate your schema. Nested maps and lists
are immutable. These are mod-owned tables, not additional global registries.
The campaign example's file is an array of objects:
[
{
"id": "settlement_trading_campaign:c2_provisions",
"stage": "c2_main",
"nameKey": "mods.settlement_trading_campaign.c2_name",
"biome": "RANDOM",
"gold": 1500,
"exports": { "trade_crate_apple": 3, "trade_crate_pear": 3 }
}
]
Keep campaign identities in data and use canonical stage names. Translate market names in all
supported locales. Resources are checked against the composed registry at startup. The API's
Market.sourceStage connects a market to a saved town; independent markets may use an empty stage.
Resource quantities are bounded to 100,000, the host export-choice cap to 1-64, travel to 1-48 days
and grants to 0-100,000 gold. The shipped policy uses the narrower player-facing limits above.
See Java extensions for lifecycle rules and saves and updates for content validation and saved-state compatibility.
Share a trading core
The historical Settlement Trading parent published a typed core shared by its dependent packs:
var core = new SettlementTradeCore(economy, productionRules);
context.registerSettlementTradeCore(core);
Its manifest has no dependency. Each extension declares:
"dependencies": { "settlement_trading": "1.5.0" }
During registration, each extension calls:
var core = context.requireSettlementTradeCore("settlement_trading");
int days = core.economy().travelDays("MEADOWS");
The loader sorts the dependency graph before executing any consumer. Missing/disabled packs and
cycles fail validation; it cannot place an extension ahead of its core. One core may be registered
per provider; lookup requires a directly declared dependency. Both operations close when the
entrypoint returns. JARs remain isolated and compile against the API JAR only; no private classes
are shared. The provider validates its production table in onRegistriesReady.
Dependency version strings record the author's tested version. A different version is probed
against actual capabilities. The native game now provides the original settlement_trading core
before optional mods register, so this declared dependency needs no installed parent pack. Other
missing providers still fail validation. Common settings are edited under Settings → Settlement Trading;
existing player overrides are retained. The Kingdom's five-day delivery and 30% purchase rate remain explicit overrides.
