Changes

Jump to navigation Jump to search
→‎What's new for items: + custom machines
Line 477: Line 477:  
| ''(Optional)'' The speed boost applied to the player, on the [[farm]] only, when they're walking on paths of this type. Negative values are ignored. Default 0.1.
 
| ''(Optional)'' The speed boost applied to the player, on the [[farm]] only, when they're walking on paths of this type. Negative values are ignored. Default 0.1.
 
|}
 
|}
 +
 +
===Custom machines===
 +
You can now add/edit machine logic by editing the <samp>Data/MachinesData</samp> asset. This consists of a string → model lookup, where the key matches the <samp>ID</samp> field and the value is a model with these fields:
 +
 +
<dl>
 +
<dt>Main behavior:</dt>
 +
<dd>
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>ItemID</samp>
 +
| The [[#Custom items|qualified or unqualified item ID]] for the item which acts as a machine (like <samp>(BC)127</samp> for [[The Cave|mushroom boxes]]).
 +
 +
If a machine has two entries, the qualified ID takes priority. To avoid mod conflicts, '''custom machines should always use unqualified item IDs''' (since custom IDs should already be unique).
 +
|-
 +
| <samp>ItemConversions</samp>
 +
| ''(Optional)'' The rules which define how to process input items. This consists of a list of models with these fields:
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>RequiredTags</samp>
 +
| A comma-delimited list of [[Modding:Context tags|context tags]] to match against input items. An item must have all of the listed tags to select this rule. You can negate a tag with <samp>!</samp> (like <code>bone_item,!fossil_item</code> for bone items that aren't fossils).
 +
|-
 +
| <samp>RequiredCount</samp>
 +
| The required stack size for the item matching <samp>RequiredTag</samp>.
 +
|-
 +
| <samp>Condition</samp>
 +
| ''(Optional)'' A [[#Game state queries|game state query]] which indicates whether the given input should be matched (if the other requirements are matched too). Item-only tokens are valid for this check. Defaults to always true.
 +
|-
 +
| <samp>OverrideOutputs</samp>
 +
| ''(Optional)'' The output items produced by this conversion rule. This uses the same format as <samp>Outputs</samp> on the machine itself. Defaults to the machine's <samp>Outputs</samp> field if omitted.
 +
|-
 +
| <samp>OverrideMinutesUntilReady</samp>
 +
| ''(Optional)'' The number of in-game minutes until the output is ready to collect. Defaults to the machine's <samp>MinutesUntilReady</samp> field if omitted.
 +
|}
 +
|-
 +
| <samp>AdditionalConsumedItems</samp>
 +
| ''(Optional)'' A list of extra items required before <samp>ItemConversions</samp> or <samp>ConversionMethod</samp> will be checked. If specified, every listed item must be present in the player, [[hopper]], or chest inventory (depending how the machine is being loaded).
 +
 +
This consists of a list of models with these fields:
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>ItemID</samp>
 +
| The [[#Custom items|qualified or unqualified item ID]] for the required item.
 +
|-
 +
| <samp>RequiredCount</samp>
 +
| ''(Optional)'' The required stack size for the item matching <samp>RequiredTag</samp>. Default 1.
 +
|-
 +
| <samp>InvalidCountMessage</samp>
 +
| ''(Optional)'' If set, overrides the machine's main <samp>InvalidCountMessage</samp> field.
 +
|}
 +
|-
 +
| <samp>Outputs</samp>
 +
| ''(Optional)'' The items produced by this machine, unless overridden by <samp>OverrideOutputs</samp> under <samp>ItemConversions</samp>. If multiple output entries match, one will be selected randomly. This consists of a list of models with these fields:
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>ItemID</samp>
 +
| The [[#Custom items|qualified or unqualified item ID]] for the produced item.
 +
|-
 +
| <samp>MinCount</samp><br /><samp>MaxCount</samp>
 +
| The minimum and maximum number of this item produced. A value in this range will chosen randomly each time it's produced. Both default to 1.
 +
|-
 +
| <samp>Condition</samp>
 +
| ''(Optional)'' A [[#Game state queries|game state query]] which indicates whether this output can be produced. Item-only tokens are valid for this check, and will check the ''input'' (not output) item. Defaults to always true.
 +
|}
 +
|-
 +
| <samp>MinutesUntilReady</samp>
 +
| ''(Optional)'' The number of in-game minutes until the output is ready to collect, unless overridden by <samp>OverrideMinutesUntilReady</samp> under <samp>ItemConversions</samp>. If both are omitted, the item will be ready instantly.
 +
|-
 +
| <samp>QuantityModifiers</samp>
 +
| ''(Optional)'' Changes to apply to the produced output's stack size. If multiple entries match, they'll be applied sequentially (e.g. two matching rules to double output will quadruple it). Note that this doesn't prevent you from setting invalid stack sizes (like negative values), which may cause in-game bugs.
 +
 +
This consists of a list of models with these fields:
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <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>
 +
| The operand applied to the item's current stack size (e.g. the multiplier if used with <samp>Multiply</samp>).
 +
|-
 +
| <samp>Condition</samp>
 +
| ''(Optional)'' A [[#Game state queries|game state query]] which indicates whether this change should be applied. Item-only tokens are valid for this check, and will check the ''input'' (not output) item. Defaults to always true.
 +
|}
 +
|-
 +
| <samp>QualityModifiers</samp>
 +
| ''(Optional)'' Changes to apply to the produced output's quality. This works exactly like <samp>QuantityModifiers</samp>, but operates on numeric qualities: 0 (normal), 1 (silver), 2 (gold), or 4 (iridium). Note that this doesn't prevent you from setting invalid qualities (like values beyond iridium), which may cause in-game bugs.
 +
|}
 +
</dd>
 +
 +
<dt>Audio & visuals:</dt>
 +
<dd>
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>LoadSound</samp>
 +
| ''(Optional)'' The [[#Custom audio|audio cue ID]] played when an item is loaded into the machine. Defaults to no sound.
 +
|-
 +
| <samp>LoadDelayedSounds</samp>
 +
| ''(Optional)'' The audio played shortly after an item is loaded into the machine. This consists of a list of models with these fields:
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>Sound</samp>
 +
| The [[#Custom audio|audio cue ID]] to play.
 +
|-
 +
| <samp>Delay</samp>
 +
| The number of milliseconds until the sound should play.
 +
|}
 +
|-
 +
| <samp>LightWhenLoaded</samp>
 +
| ''(Optional)'' Whether the machine produces light while it's processing an item. Default false.
 +
|-
 +
| <samp>ShowNextIndexWhenLoaded</samp>
 +
| ''(Optional)'' Whether to increment the machine's spritesheet index by one  while it's processing an item. Default false.
 +
|-
 +
| <samp>LoadTemporarySprites</samp>
 +
| ''(Optional)'' The temporary animated sprites to show after an item is loaded into the machine. This consists of a list of models with these fields:
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>Texture</samp>
 +
| The asset name for the texture (under the game's <samp>Content</samp> folder) for the animated sprite.
 +
|-
 +
| <samp>SourceRect</samp>
 +
| The pixel area for the first animated frame within the <samp>Texture</samp>, specified as an object with <samp>X</samp>, <samp>Y</samp>, <samp>Width</samp>, and <samp>Height</samp> fields.
 +
|-
 +
| <samp>PositionOffset</samp>
 +
| ''(Optional)'' A pixel offset applied to the sprite, relative to the top-left corner of the machine's collision box, specified as an object with <samp>X</samp> and <samp>Y</samp> fields. Defaults to (0, 0).
 +
|-
 +
| <samp>AlphaFade</samp><br /><samp>Loops</samp><br /><samp>Rotation</samp><br /><samp>RotationChange</samp><br /><samp>ScaleChange</samp><br /><samp>SortOffset</samp>
 +
| ''(Optional)'' See equivalent fields in the [[#Other changes|<samp>temporaryAnimatedSprite</samp> event command]]. Default 0.
 +
|-
 +
| <samp>Frames</samp><br /><samp>Scale</samp>
 +
| ''(Optional)'' See equivalent fields in the [[#Other changes|<samp>temporaryAnimatedSprite</samp> event command]]. Default 1.
 +
|-
 +
| <samp>Interval</samp>
 +
| ''(Optional)'' See equivalent fields in the [[#Other changes|<samp>temporaryAnimatedSprite</samp> event command]]. Default 100.
 +
|-
 +
| <samp>Flicker</samp><br /><samp>Flip</samp>
 +
| ''(Optional)'' See equivalent fields in the [[#Other changes|<samp>temporaryAnimatedSprite</samp> event command]]. Default false.
 +
|}
 +
|}
 +
</dd>
 +
 +
<dt>Player interaction messages:</dt>
 +
<dd>
 +
These only apply when the player interacts with a chest directly, instead of using a [[hopper]] or mod like {{nexus mod|1063|Automate}}.
 +
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>InvalidItemMessage</samp>
 +
| ''(Optional)'' A [[#Tokenizable string format|tokenizable string]] for the message shown in a toaster notification if the player tries to input an item that isn't accepted by the machine.
 +
|-
 +
| <samp>InvalidCountMessage</samp>
 +
| ''(Optional)'' A [[#Tokenizable string format|tokenizable string]] for the message shown in a toaster notification if the input inventory doesn't contain this item, unless overridden by <samp>InvalidCountMessage</samp> under <samp>ItemConversions</samp>.
 +
|}
 +
</dd>
 +
 +
<dl>
 +
<dt>Advanced logic:</dt>
 +
<dd>
 +
{| class="wikitable"
 +
|-
 +
! field
 +
! effect
 +
|-
 +
| <samp>ConversionMethod</samp>
 +
| ''(Optional)'' A C# method which applies custom processing logic. This must be specified in the form <samp>{{t|full type name}}.{{t|method name}}</samp> (like <samp>StardewValley.Object.DropInDeconstructor</samp>). The method must be static, take five arguments (<code>Item machine, Item dropped_in_item, Farmer farmer, bool probe, ref Item output</code>), and return a boolean indicating whether the input was successfully processed.
 +
 +
⚠️ Caveats:
 +
* This will completely disable the <samp>ItemConversions</samp>, <samp>InvalidItemMessage</samp>, <samp>InvalidCountMessage</samp>, and <samp>Outputs</samp> fields.
 +
* This will prevent any other mod from registering their own processing rules for this machine.
 +
* This will prevent {{nexus mod|1063|Automate}} from automating the machine, since it has no way to know which items will be accepted by the method. For Automate support, you'd need to [https://github.com/Pathoschild/StardewMods/blob/develop/Automate/docs/technical.md#extensibility-for-modders use Automate's API] to register a custom machine factory to handle it in code.
 +
* This should ''only'' perform conversion logic. Don't handle interaction logic like animations, sounds, or UI messages in this method, since that'll interfere with [[hopper]]s and other machine mods. See the other fields instead for that.
 +
|}
 +
</dd>
    
===Custom museum donations & rewards===
 
===Custom museum donations & rewards===
translators
8,446

edits

Navigation menu