Changes

Jump to navigation Jump to search
Line 234: Line 234:  
For example, [[pufferfish]] has two item IDs: <code>128</code> (unqualified) and <code>(O)128</code> (qualified).
 
For example, [[pufferfish]] has two item IDs: <code>128</code> (unqualified) and <code>(O)128</code> (qualified).
   −
See [[Modding:Migrate to Stardew Valley 1.6#Custom items]] for more info.
+
See [[Modding:Items]] for more info.
    
===Item query===
 
===Item query===
Line 298: Line 298:  
     "Y": 0
 
     "Y": 0
 
}
 
}
 +
</syntaxhighlight>
 +
 +
===Quantity modifiers===
 +
 +
''Quantity modifiers'' apply dynamic changes to a numeric field in a data asset like [[#Custom shops|<samp>Data/Shops</samp>]] or [[#Custom machines|<samp>Data/Machines</samp>]]. For example, you can multiply a shop item's price or increase a machine output's quality. You can specify any number of modifiers for the same field.
 +
 +
====Modifier format====
 +
These consist of a list of models with these fields:
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>Id</samp>
 +
| The [[Modding:Common data field types#Unique string ID|unique string ID]] for this modifier within the current list.
 +
|-
 +
| <samp>Modification</samp>
 +
| The type of change to apply. The possible values are <samp>Add</samp>, <samp>Subtract</samp>, <samp>Multiply</samp>, <samp>Divide</samp>, and <samp>Set</samp>.
 +
|-
 +
| <samp>Amount</samp>
 +
| ''(Optional if <samp>RandomAmount</samp> specified)'' The operand applied to the target value (e.g. the multiplier if used with <samp>Multiply</samp>).
 +
|-
 +
| <samp>RandomAmount</samp>
 +
| ''(Optional)'' A list of possible amounts to randomly choose from. If set, <samp>Amount</samp> is optional and ignored. Each entry in the list has an equal probability of being chosen, and the choice is persisted for the current day. For example:
 +
<syntaxhighlight lang="js">
 +
"RandomAmount": [ 1, 2, 3.5, 4 ]
 +
</syntaxhighlight>
 +
|-
 +
| <samp>Condition</samp>
 +
| ''(Optional)'' A [[Modding:Game state queries|game state query]] which indicates whether this change should be applied. Defaults to always true.
 +
|}
 +
 +
====Modifier mode====
 +
Quality modifier fields are often accompanied by a ''mode'' field (like <samp>PriceModifiers</samp> and <samp>PriceModifierMode</samp>), which indicate what to do when multiple modifiers apply to the same value. Available modes:
 +
 +
{| class="wikitable"
 +
|-
 +
! value
 +
! effect
 +
|-
 +
| <samp>Stack</samp>
 +
| Apply each modifier to the result of the previous one. For example, two modifiers which double a value will quadruple it.
 +
|-
 +
| <samp>Minimum</samp>
 +
| Apply the modifier which results in the lowest value.
 +
|-
 +
| <samp>Maximum</samp>
 +
| Apply the modifier which results in the highest value.
 +
|}
 +
 +
====Examples====
 +
For example, this will double the price of a shop item in <samp>Data/Shops</samp>:
 +
<syntaxhighlight lang="js">
 +
"PriceModifiers": [
 +
    {
 +
        "Modification": "Multiply",
 +
        "Amount": 2.0
 +
    }
 +
]
 +
</syntaxhighlight>
 +
 +
This will set the price to a random value between 100–1000, ''or'' 3–5 times the item's normal sell price, whichever is higher (like the [[Traveling Cart]]):
 +
<syntaxhighlight lang="js">
 +
"PriceModifierMode": "Maximum",
 +
"PriceModifiers": [
 +
    {
 +
        "Modification": "Set",
 +
        "RandomAmount": [ 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 ]
 +
    },
 +
    {
 +
        "Modification": "Multiply",
 +
        "RandomAmount": [ 3, 4, 5 ]
 +
    }
 +
]
 
</syntaxhighlight>
 
</syntaxhighlight>
  
138

edits

Navigation menu