scene_add_shop
Creates a buy-and-sell shop in a copied save from a prefab stall by defining sell and buy lists with items, currencies, prices, and optional stock.
Instructions
Make a prefab a shop (商店) in a copy of a save: the platform's own buying and selling screen, which moves items and currency between the shop and the backpack of the character without any graph. sell lists what the shop sells to the player, buy what it buys from the player; each line is {item, currency, price} with the item and the currency by name or id (scene_add_item, scene_add_currency), and a line of sell may give stock (how many the shop has; 1 when left out, as in the official lesson). prefab is the stall, a prefab from scene_add_prefab. A graph opens the shop for a player with f.openShop(player, the stall entity, 1), in the official lesson when a character enters the stall's collision trigger, and f.closeShop(player) closes it; whenCustomShopItemIsSold (the shop sold something) and whenSellingItemsToTheShop (the player sold something) fire in a graph on the stall. The shop template and the shop component written are byte for byte those of the official sample 货币与商店 (which has one line in each list). Verified in play on 2026-10-11 (examples/shop): the screen shows the shelf on the left with each line's icon, stock and price, and the backpack on the right; a click on a line and on 购买 buys (the currency goes down, the item goes into the backpack, a sold-out line is marked 已售罄); 批量出售, a click on an item of the backpack and 出售 sells at the price of the buy list, not at the item's value. It works on an account of 奇匠 level 1. To play it by script, playtest_start takes click and clickText inputs. Writes a new .gil in the workspace; the official save is not touched.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| buy | No | ||
| name | Yes | ||
| sell | No | ||
| prefab | Yes | ||
| mapPath | No | ||
| outputName | No |