Changes

Jump to navigation Jump to search
copy item spawn fields section as-is from Modding:Migrate to Stardew Valley 1.6 (all content by Pathoschild)
Line 153: Line 153:  
| <samp>TOOL_UPGRADES {{o|tool ID}}</samp>
 
| <samp>TOOL_UPGRADES {{o|tool ID}}</samp>
 
| The tool upgrades listed in <samp>Data/Shops</samp> whose conditions match the player's inventory (i.e. the same rules as [[Blacksmith|Clint's tool upgrade shop]]). If {{o|tool ID}} is specified, only upgrades which consume that tool ID are shown.
 
| The tool upgrades listed in <samp>Data/Shops</samp> whose conditions match the player's inventory (i.e. the same rules as [[Blacksmith|Clint's tool upgrade shop]]). If {{o|tool ID}} is specified, only upgrades which consume that tool ID are shown.
 +
|}
 +
 +
==Item spawn fields==
 +
Several data assets (like [[#Custom machines|machines]] and [[#Custom shops|shops]]) let you configure items to create. For consistency, these all share a set of common fields (internally represented by <samp>ISpawnItemData</samp>, and <samp>GenericSpawnItemData</samp> or <samp>GenericSpawnItemDataWithCondition</samp>):
 +
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>ID</samp>
 +
| The [[Modding:Modder Guide/Game Fundamentals#Unique string IDs|unique string ID]] for this entry (not the item itself) within the current list.
 +
 +
This is semi-optional — if omitted, it'll be auto-generated from the <samp>ItemId</samp>, <samp>RandomItemId</samp>, and <samp>IsRecipe</samp> fields. However multiple entries with the same ID may cause unintended behavior (e.g. shop items reducing each others' stock limits), so it's often a good idea to set a globally unique ID instead.
 +
|-
 +
| <samp>ItemId</samp>
 +
| One of:
 +
* the [[#Custom items|qualified or unqualified item ID]] (like <samp>(O)128</samp> for a [[pufferfish]]);
 +
* or an [[#Item queries|item query]] to dynamically choose one or more items.
 +
|-
 +
| <samp>RandomItemId</samp>
 +
| ''(Optional)'' A list of item IDs to randomly choose from, using the same format as <samp>ItemId</samp> (including item queries). If set, <samp>ItemId</samp> is optional and ignored. Each entry in the list has an equal probability of being chosen. For example:
 +
<syntaxhighlight lang="js">
 +
// wood, stone, or pizza
 +
"RandomItemId": [ "(O)388", "(O)390", "(O)206" ]
 +
</syntaxhighlight>
 +
|-
 +
| <samp>Condition</samp>
 +
| ''(Optional)'' A [[Modding:Game state queries|game state query]] which indicates whether this entry should be applied. Defaults to always true.
 +
 +
'''Note:''' not supported for weapon projectiles.
 +
|-
 +
| <samp>PerItemCondition</samp>
 +
| ''(Optional)'' A [[Modding:Game state queries|game state query]] which indicates whether an item produced from the other fields should be returned. Defaults to always true.
 +
 +
For example, this can be used to filter queries like <samp>RANDOM_ITEMS</samp>:
 +
<syntaxhighlight lang="js">
 +
// random mineral
 +
"ItemId": "RANDOM_ITEMS (O)",
 +
"PerItemCondition": "ITEM_CATEGORY Target -12"
 +
</syntaxhighlight>
 +
|-
 +
| <samp>MaxItems</samp>
 +
| ''(Optional)'' If this entry produces multiple separate item stacks, the maximum number to return. (This does ''not'' affect the size of each stack; see <samp>MinStack</samp> and <samp>MaxStack</samp> for that.) Default unlimited.
 +
|-
 +
| <samp>IsRecipe</samp>
 +
| ''(Optional)'' Whether to get the crafting/cooking recipe for the item, instead of the item itself. Default false.
 +
|-
 +
| <samp>Quality</samp>
 +
| ''(Optional)'' The quality of the item to find. One of <samp>0</samp> (normal), <samp>1</samp> (silver), <samp>2</samp> (gold), or <samp>4</samp> (iridium). Invalid values will snap to the closest valid one (e.g. <samp>7</samp> will become iridium). Default -1, which keeps the value set by the item query (usually 0).
 +
|-
 +
| <samp>MinStack</samp>
 +
| ''(Optional)'' The item's minimum and default stack size. Default -1, which keeps the value set by the item query (usually 1).
 +
|-
 +
| <samp>MaxStack</samp>
 +
| ''(Optional)'' If set to a value higher than <samp>MinStack</samp>, the stack is set to a random value between them (inclusively). Default -1.
 +
|-
 +
| <samp>ObjectDisplayName</samp>
 +
| ''(Optional)'' For objects only, a [[Modding:Tokenizable strings|tokenizable string]] for the item's display name. Defaults to the item's display name in <samp>Data/Objects</samp>. This can optionally contain <code>%DISPLAY_NAME</code> (the item's default display name) and <code>%PRESERVED_DISPLAY_NAME</code> (the preserved item's display name if applicable, ''e.g.'' if set via <samp>PreserveId</samp> in [[#Custom machines|machine data]]).
 +
 +
'''Careful:''' text in this field will be saved permanently in the object's info and won't be updated when the player changes language or the content pack changes. That includes Content Patcher translations (like <code><nowiki>%DISPLAY_NAME {{i18n: wine}}</nowiki></code>), which will save the translated text for the current language. Instead, add the text to a strings asset like <samp>Strings/Objects</samp> and then use the [[Modding:Tokenizable strings|<samp>[LocalizedText]</samp> token]].
 +
{{collapse|For example, here's how you'd create flavored oils with Content Patcher:|content=
 +
<ol>
 +
<li>Add the display name to [[Modding:Translations|your <samp>i18n/default.json</samp> file]] (with <samp>{0}</samp> where you want the flavor name):
 +
<syntaxhighlight lang="json">
 +
{
 +
    "flavored-oil": "{0} Oil"
 +
}
 +
</syntaxhighlight></li>
 +
<li>Add the text to a strings asset visible to the game:
 +
{{#tag:syntaxhighlight|<nowiki>
 +
{
 +
    "Format": "</nowiki>{{Content Patcher version}}<nowiki>",
 +
    "Changes": [
 +
        {
 +
            "Action": "EditData",
 +
            "Target": "Strings/Objects",
 +
            "Entries": {
 +
                "Example.ModId_Oil": "{{i18n: flavored-oil}}"
 +
            }
 +
        }
 +
}</nowiki>|lang=javascript}}</li>
 +
<li>Use the [[Modding:Tokenizable strings|<samp>[LocalizedText]</samp> token]] to get your translation, and pass in the flavor as an argument:
 +
<syntaxhighlight lang="json">
 +
"ObjectDisplayName": "[LocalizedText Strings/Objects:Example.ModId_Oil %PRESERVED_DISPLAY_NAME]",
 +
</syntaxhighlight>
 +
</ol>
 +
 +
Now when the player changes language, the object will automatically get the new translation from <samp>Strings/Object</samp>.
 +
}}
 +
|-
 +
| <samp>ToolUpgradeLevel</samp>
 +
| ''(Optional)'' For tools only, the initial upgrade level for the tool when created (like [[Axes|Copper vs Gold Axe]], or [[Training Rod]] vs [[Iridium Rod]]). Default -1, which keeps the value set by the item query (usually 0).
 +
|-
 +
| <samp>QualityModifiers</samp><br /><samp>StackModifiers</samp>
 +
| ''(Optional)'' [[#Quantity modifiers|Quantity modifiers]] applied to the <samp>Quality</samp> or <samp>Stack</samp> value. Default none.
 +
 +
The quality modifiers operate on the numeric quality values (''i.e.'' <samp>0</samp> = normal, <samp>1</samp> = silver, <samp>2</samp> = gold, and <samp>4</samp> = iridium). For example, silver × 2 is gold.
 +
|-
 +
| <samp>QualityModifierMode</samp><br /><samp>StackModifierMode</samp>
 +
| ''(Optional)'' [[#Quantity modifiers|quantity modifier modes]] which indicate what to do if multiple modifiers in the <samp>QualityModifiers</samp> or <samp>StackModifiers</samp> field apply at the same time. Default <samp>Stack</samp>.
 
|}
 
|}
    
[[Category:Modding]]
 
[[Category:Modding]]
translators
8,445

edits

Navigation menu