Traders
Things to know
AddTraderStockkeepsamountof the item in the trader’s shop. The trader gets back whatever is missing every time the save loads and every time the shop restocks, but only into empty slots. It returnstruewhen your request is kept, even if the shop is not loaded yet. Calling it again for the same mod, shop and item replaces the amount. (The framework counts that item in the trader’sStorageand adds the missing amount, afterStorage.OnLoadingGameand afterStorage.SpawnItems.)Placeputsamountof the item into the trader’s empty slots once, for each save. It returnstruewhen at least one item was placed. A second call for the same mod, shop and item returnsfalse, because the framework remembers it in the save. A shop without an id can’t be used withPlace. (The record is kept per save, keyed by the mod, the shop GUID and the item.)Removetakes back your request, but not the items already on the shelf. It returnstruewhen it found a trader request or a vending entry of yours for that shop and item. It also removes the vending entry from machines that are loaded right now.
Limits
- If another mod keeps the same item in the same shop, both requests are kept and the larger amount wins. Each one tops up to its own amount, and one warning names both mods. If you use two different keys that match the same shop (the id and the title, for example), the framework does not notice.
- Stock goes only into empty slots. If there is no empty slot, the rest is skipped and one warning goes to the log. The game limits each stack to the item’s stack size.