Difference between revisions of "Modding:Shops"
Pathoschild (talk | contribs) (integrate copied text into new page) |
Pathoschild (talk | contribs) (fix links after move) |
||
Line 22: | Line 22: | ||
|- | |- | ||
| ''common fields'' | | ''common fields'' | ||
− | | See [[#Item spawn fields|item spawn fields]] for the generic item fields supported by shop items. | + | | See [[Modding:Migrate to Stardew Valley 1.6#Item spawn fields|item spawn fields]] for the generic item fields supported by shop items. |
Notes: | Notes: | ||
− | * If set to an [[#Item queries|item query]] which returns multiple items, all of them will be added to the shop. | + | * If set to an [[Modding:Migrate to Stardew Valley 1.6#Item queries|item query]] which returns multiple items, all of them will be added to the shop. |
* The <samp>MinStack</samp> and <samp>MaxStack</samp> fields apply to the item after it's purchased, and have no effect on the price or <samp>Stock</samp> limit. | * The <samp>MinStack</samp> and <samp>MaxStack</samp> fields apply to the item after it's purchased, and have no effect on the price or <samp>Stock</samp> limit. | ||
* If the player found [[Pierre's Missing Stocklist]], season conditions in the <samp>Condition</samp> field are ignored in [[Pierre's General Store]]. | * If the player found [[Pierre's Missing Stocklist]], season conditions in the <samp>Condition</samp> field are ignored in [[Pierre's General Store]]. | ||
Line 33: | Line 33: | ||
|- | |- | ||
| <samp>TradeItemId</samp><br /><samp>TradeItemAmount</samp> | | <samp>TradeItemId</samp><br /><samp>TradeItemAmount</samp> | ||
− | | ''(Optional)'' The [[#Custom items|qualified or unqualified item ID]] and amount which must be traded to purchase this item. Defaults to no item and 1 respectively. | + | | ''(Optional)'' The [[Modding:Migrate to Stardew Valley 1.6#Custom items|qualified or unqualified item ID]] and amount which must be traded to purchase this item. Defaults to no item and 1 respectively. |
If both <samp>Price</samp> and <samp>TradeItemId</samp> are specified, the player will have to provide both to get the item. | If both <samp>Price</samp> and <samp>TradeItemId</samp> are specified, the player will have to provide both to get the item. | ||
Line 44: | Line 44: | ||
|- | |- | ||
| <samp>AvailableStockModifiers</samp><br /><samp>PriceModifiers</samp> | | <samp>AvailableStockModifiers</samp><br /><samp>PriceModifiers</samp> | ||
− | | ''(Optional)'' [[#Quantity modifiers|Quantity modifiers]] applied to the <samp>AvailableStock</samp> or <samp>Price</samp> values. | + | | ''(Optional)'' [[Modding:Migrate to Stardew Valley 1.6#Quantity modifiers|Quantity modifiers]] applied to the <samp>AvailableStock</samp> or <samp>Price</samp> values. |
Notes: | Notes: | ||
Line 50: | Line 50: | ||
|- | |- | ||
| <samp>AvailableStockModifierMode</samp><br /><samp>PriceModifierMode</samp> | | <samp>AvailableStockModifierMode</samp><br /><samp>PriceModifierMode</samp> | ||
− | | ''(Optional)'' [[#Quantity modifiers|quantity modifier modes]] which indicate what to do if multiple modifiers in the <samp>AvailableStockModifiers</samp> or <samp>PriceModifiers</samp> field apply at the same time. Default <samp>Stack</samp>. | + | | ''(Optional)'' [[Modding:Migrate to Stardew Valley 1.6#Quantity modifiers|quantity modifier modes]] which indicate what to do if multiple modifiers in the <samp>AvailableStockModifiers</samp> or <samp>PriceModifiers</samp> field apply at the same time. Default <samp>Stack</samp>. |
|- | |- | ||
| <samp>AvoidRepeat</samp> | | <samp>AvoidRepeat</samp> | ||
Line 89: | Line 89: | ||
| ''(Optional)'' The portrait and dialogue to show in the shop menu UI, ''or'' the message to show indicating that the shop is closed if <samp>ClosedMessage</samp> is set. | | ''(Optional)'' The portrait and dialogue to show in the shop menu UI, ''or'' the message to show indicating that the shop is closed if <samp>ClosedMessage</samp> is set. | ||
− | When the [[#Map/tile property changes|<samp>Action OpenShop</samp> tile property]] specifies {{o|owner tile area}}, the first NPC within the tile area which matches an owner entry is used; if no NPCs match, the shop isn't opened. If <samp>Owners</samp> is omitted, the shop is opened regardless of whether an NPC is present, and no portrait or dialogue is shown. | + | When the [[Modding:Migrate to Stardew Valley 1.6#Map/tile property changes|<samp>Action OpenShop</samp> tile property]] specifies {{o|owner tile area}}, the first NPC within the tile area which matches an owner entry is used; if no NPCs match, the shop isn't opened. If <samp>Owners</samp> is omitted, the shop is opened regardless of whether an NPC is present, and no portrait or dialogue is shown. |
This consists of a list of models with these fields: | This consists of a list of models with these fields: | ||
Line 181: | Line 181: | ||
|- | |- | ||
| <samp>OpenSound</samp> | | <samp>OpenSound</samp> | ||
− | | ''(Optional)'' The [[#Custom audio|audio cue ID]] to play when the shop menu is opened. Defaults to <samp>dwop</samp>. | + | | ''(Optional)'' The [[Modding:Migrate to Stardew Valley 1.6#Custom audio|audio cue ID]] to play when the shop menu is opened. Defaults to <samp>dwop</samp>. |
|- | |- | ||
| <samp>PurchaseSound</samp> | | <samp>PurchaseSound</samp> | ||
− | | ''(Optional)'' The [[#Custom audio|audio cue ID]] to play when an item is purchased normally. Defaults to <samp>purchaseClick</samp>. | + | | ''(Optional)'' The [[Modding:Migrate to Stardew Valley 1.6#Custom audio|audio cue ID]] to play when an item is purchased normally. Defaults to <samp>purchaseClick</samp>. |
|- | |- | ||
| <samp>purchaseRepeatSound</samp> | | <samp>purchaseRepeatSound</samp> | ||
− | | ''(Optional)'' The [[#Custom audio|audio cue ID]] to play when accumulating a stack to purchase (e.g. by holding right-click on PC). Defaults to <samp>purchaseRepeat</samp>. | + | | ''(Optional)'' The [[Modding:Migrate to Stardew Valley 1.6#Custom audio|audio cue ID]] to play when accumulating a stack to purchase (e.g. by holding right-click on PC). Defaults to <samp>purchaseRepeat</samp>. |
|- | |- | ||
| <samp>PriceModifiers</samp> | | <samp>PriceModifiers</samp> | ||
− | | ''(Optional)'' [[#Quantity modifiers|Quantity modifiers]] applied to the sell price for items in this shop. See also <samp>PriceModifiers</samp> under <samp>Items</samp>. | + | | ''(Optional)'' [[Modding:Migrate to Stardew Valley 1.6#Quantity modifiers|Quantity modifiers]] applied to the sell price for items in this shop. See also <samp>PriceModifiers</samp> under <samp>Items</samp>. |
|- | |- | ||
| <samp>PriceModifierMode</samp> | | <samp>PriceModifierMode</samp> | ||
− | | ''(Optional)'' A [[#Quantity modifiers|quantity modifier mode]] which indicates what to do if multiple modifiers in the <samp>PriceModifiers</samp> field apply at the same time. This only affects that specific field, it won't affect price modifiers under <samp>Items</samp>. Default <samp>Stack</samp>. | + | | ''(Optional)'' A [[Modding:Migrate to Stardew Valley 1.6#Quantity modifiers|quantity modifier mode]] which indicates what to do if multiple modifiers in the <samp>PriceModifiers</samp> field apply at the same time. This only affects that specific field, it won't affect price modifiers under <samp>Items</samp>. Default <samp>Stack</samp>. |
|- | |- | ||
| <samp>VisualTheme</samp> | | <samp>VisualTheme</samp> | ||
Line 217: | Line 217: | ||
|- | |- | ||
| <samp>DialogueColor</samp><br /><samp>DialogueShadowColor</samp> | | <samp>DialogueColor</samp><br /><samp>DialogueShadowColor</samp> | ||
− | | ''(Optional)'' The sprite text color for the dialogue text. See [[#Color fields|color format]]. Defaults to the game's standard text color. | + | | ''(Optional)'' The sprite text color for the dialogue text. See [[Modding:Migrate to Stardew Valley 1.6#Color fields|color format]]. Defaults to the game's standard text color. |
|- | |- | ||
| <samp>ItemRowBackgroundTexture</samp><br /><samp>ItemRowBackgroundSourceRect</samp> | | <samp>ItemRowBackgroundTexture</samp><br /><samp>ItemRowBackgroundSourceRect</samp> | ||
Line 223: | Line 223: | ||
|- | |- | ||
| <samp>ItemRowBackgroundHoverColor</samp> | | <samp>ItemRowBackgroundHoverColor</samp> | ||
− | | ''(Optional)'' The color tint to apply to the item row background in the shop inventory when the cursor is hovering over it, or <samp>White</samp> for no tint. See [[#Color fields|color format]]. Defaults to <samp>Wheat</samp>. | + | | ''(Optional)'' The color tint to apply to the item row background in the shop inventory when the cursor is hovering over it, or <samp>White</samp> for no tint. See [[Modding:Migrate to Stardew Valley 1.6#Color fields|color format]]. Defaults to <samp>Wheat</samp>. |
|- | |- | ||
| <samp>ItemRowTextColor</samp> | | <samp>ItemRowTextColor</samp> | ||
− | | ''(Optional)'' The sprite text color for the item text. See [[#Color fields|color format]]. Defaults to the game's standard text color. | + | | ''(Optional)'' The sprite text color for the item text. See [[Modding:Migrate to Stardew Valley 1.6#Color fields|color format]]. Defaults to the game's standard text color. |
|- | |- | ||
| <samp>ItemIconBackgroundTexture</samp><br /><samp>ItemIconBackgroundSourceRect</samp> | | <samp>ItemIconBackgroundTexture</samp><br /><samp>ItemIconBackgroundSourceRect</samp> | ||
Line 245: | Line 245: | ||
|- | |- | ||
| <samp>CustomFields</samp> | | <samp>CustomFields</samp> | ||
− | | The [[#Custom data fields|custom fields]] for this entry. | + | | The [[Modding:Migrate to Stardew Valley 1.6#Custom data fields|custom fields]] for this entry. |
|} | |} | ||
Line 446: | Line 446: | ||
==Open a custom shop== | ==Open a custom shop== | ||
− | You can place an [[#Map/tile property changes|<samp>Action OpenShop</samp> tile property]] on the map, which will open the given shop ID when the player clicks it. | + | You can place an [[Modding:Migrate to Stardew Valley 1.6#Map/tile property changes|<samp>Action OpenShop</samp> tile property]] on the map, which will open the given shop ID when the player clicks it. |
In C# code, you can get the inventory for a custom shop using <code>Utility.GetShopStock("shop id here")</code>, open a shop menu using <code>Utility.TryOpenShopMenu("shop id", …)</code>, and add temporary items to an open menu using <code>shopMenu.AddForSale(…)</code>. The ID of the opened shop is stored in the shop menu's <samp>storeContext</samp> field. | In C# code, you can get the inventory for a custom shop using <code>Utility.GetShopStock("shop id here")</code>, open a shop menu using <code>Utility.TryOpenShopMenu("shop id", …)</code>, and add temporary items to an open menu using <code>shopMenu.AddForSale(…)</code>. The ID of the opened shop is stored in the shop menu's <samp>storeContext</samp> field. | ||
[[Category:Modding]] | [[Category:Modding]] |
Revision as of 05:09, 4 December 2023
← Index
This page explains how to edit shop data.
Data
Format
You can create and change shops by editing the Data/Shops asset. This consists of a string → model lookup, where the key is a unique string ID for the shop, and the value is a model with these fields.
field | effect | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Items | The items to add to the shop inventory. This consists of a list of values with these fields:
| ||||||||||||||||||||||||||||||||
SalableItemTags | (Optional) A list of context tags for items which the player can sell to to this shop. Default none. | ||||||||||||||||||||||||||||||||
Owners | (Optional) The portrait and dialogue to show in the shop menu UI, or the message to show indicating that the shop is closed if ClosedMessage is set.
When the Action OpenShop tile property specifies This consists of a list of models with these fields:
| ||||||||||||||||||||||||||||||||
Currency | (Optional) The currency in which all items in the shop should be priced. The valid values are 0 (money), 1 (star tokens), 2 (Qi coins), and 4 (Qi gems). Default 0. For item trading, see TradeItemId for each item. | ||||||||||||||||||||||||||||||||
ApplyProfitMargins | (Optional) The default value for ApplyProfitMargins under Items, if set. This can be true (always apply it), false (never apply it), or null (apply for certain items like saplings). This is applied before any quantity modifiers. Default null. | ||||||||||||||||||||||||||||||||
StackSizeVisibility | (Optional) How to draw stack size numbers in the shop list by default. If omitted, the default shop logic is applied (usually equivalent to Show).
The possible values are:
This is ignored in some special cases (e.g. recipes can't have a stack size). | ||||||||||||||||||||||||||||||||
OpenSound | (Optional) The audio cue ID to play when the shop menu is opened. Defaults to dwop. | ||||||||||||||||||||||||||||||||
PurchaseSound | (Optional) The audio cue ID to play when an item is purchased normally. Defaults to purchaseClick. | ||||||||||||||||||||||||||||||||
purchaseRepeatSound | (Optional) The audio cue ID to play when accumulating a stack to purchase (e.g. by holding right-click on PC). Defaults to purchaseRepeat. | ||||||||||||||||||||||||||||||||
PriceModifiers | (Optional) Quantity modifiers applied to the sell price for items in this shop. See also PriceModifiers under Items. | ||||||||||||||||||||||||||||||||
PriceModifierMode | (Optional) A quantity modifier mode which indicates what to do if multiple modifiers in the PriceModifiers field apply at the same time. This only affects that specific field, it won't affect price modifiers under Items. Default Stack. | ||||||||||||||||||||||||||||||||
VisualTheme | (Optional) The visual theme to apply to the shop UI, or omit to use the default theme. The first matching theme is applied. All fields are optional and will fallback to the default theme.
This consists of a list of models with these fields:
| ||||||||||||||||||||||||||||||||
CustomFields | The custom fields for this entry. |
Examples
You can add or replace entire shops. For example, this content pack adds a shop that sells ice cream in summer, and pufferfish all year:
{
"Format": "2.0.0",
"Changes": [
{
"Action": "EditData",
"Target": "Data/Shops",
"Entries": {
"Example.ModId_CustomShop": {
"Owners": [
{
"Name": "Any",
"Dialogues": [
// dialogue on sunny summer days
{
"Id": "Example.ModId_SunnySummer",
"Condition": "SEASON Summer, WEATHER Here Sun",
"Dialogue": "Ice-cream is perfect for a day like this."
},
// dialogue any other time
{
"Id": "Example.ModId_Default",
"Dialogue": "Welcome to the only place in town for pufferfish!"
}
]
}
],
"Items": [
// ice-cream in summer, default price
{
"Id": "Example.ModId_IceCream",
"Condition": "SEASON Summer",
"ItemId": "(O)233"
},
// pufferfish for 1000g, limited to one per day per player
{
"Id": "Example.ModId_PufferFish",
"ItemId": "(O)128",
"Price": 1000,
"AvailableStock": 1,
"AvailableStockLimit": "Player"
}
]
}
}
}
]
}
You can also add, replace, edit, or reorder items in a specific shop by targeting the shop's Items field. For example, this removes Trout Soup (item #219) and adds Pufferfish above bait (item #685):
{
"Format": "2.0.0",
"Changes": [
{
"Action": "EditData",
"Target": "Data/Shops",
"TargetField": [ "FishShop", "Items" ],
"Entries": {
"(O)219": null,
"Example.ModId_Pufferfish": {
"Id": "Example.ModId_Pufferfish",
"ItemId": "(O)128",
"Price": 2000
}
},
"MoveEntries": [
{ "Id": "Example.ModId_Pufferfish", "BeforeId": "(O)685" }
]
}
]
}
Vanilla shop IDs
Vanilla shops are now defined in Data/Shops too (except a few special cases like dressers and home renovations).
See Data/Shops for a full list, but here are the main shop IDs for convenience:
shop | ID |
---|---|
Abandoned house shop | HatMouse |
Adventurer's Guild | AdventureShop (regular shop) AdventureGuildRecovery (item recovery service) |
Casino | Casino |
Clint's blacksmith shop | Blacksmith (regular shop) ClintUpgrade (tool upgrades) |
Desert trader | DesertTrade |
Dwarf's shop | Dwarf |
Harvey's clinic | Hospital |
Ice-cream stand | IceCreamStand |
Island resort | ResortBar |
Island trader | IslandTrade |
Joja Mart | Joja |
Krobus' shop | ShadowShop |
Marnie's ranch | AnimalShop |
Pierre's general store | SeedShop |
Robin's carpenter shop | Carpenter |
Stardrop Saloon | Saloon |
Sandy's Oasis shop | Sandy |
Traveling cart | Traveler |
Willy's fish shop | FishShop |
Festival shops are also defined in Data/Shops now, though they can still be defined in the pre-1.6 way for backwards compatibility.
festival shop | ID |
---|---|
Dance of the Moonlight Jellies | Festival_DanceOfTheMoonlightJellies_Pierre |
Egg Festival | Festival_EggFestival_Pierre |
Festival of Ice | Festival_FestivalOfIce_TravelingMerchant |
Feast of the Winter Star | Festival_FeastOfTheWinterStar_Pierre |
Flower Dance | Festival_FlowerDance_Pierre |
Luau | Festival_Luau_Pierre |
Night Market (decoration boat) | Festival_NightMarket_DecorationBoat |
Night Market (magic boat) | Festival_NightMarket_MagicBoat_Day1 Festival_NightMarket_MagicBoat_Day2 Festival_NightMarket_MagicBoat_Day3 |
Spirit's Eve | Festival_SpiritsEve_Pierre |
Stardew Valley Fair | Festival_StardewValleyFair_StarTokens |
And two special 'shops':
item | ID |
---|---|
Catalogue | Catalogue |
Furniture Catalogue | Furniture Catalogue |
Open a custom shop
You can place an Action OpenShop tile property on the map, which will open the given shop ID when the player clicks it.
In C# code, you can get the inventory for a custom shop using Utility.GetShopStock("shop id here")
, open a shop menu using Utility.TryOpenShopMenu("shop id", …)
, and add temporary items to an open menu using shopMenu.AddForSale(…)
. The ID of the opened shop is stored in the shop menu's storeContext field.