Changes

Jump to navigation Jump to search
Line 908: Line 908:     
===Custom machines===
 
===Custom machines===
You can now add/edit machine logic by editing the <samp>Data/Machines</samp> asset.
+
: ''Main article: [[Modding:Machines]].''
   −
This consists of a string → model lookup, where...
+
You can now add/edit machine logic by editing the <samp>Data/Machines</samp> asset. This supports the full range of vanilla functionality, including calling custom code define in C# mods.
* The key is the [[#Custom items|'''qualified''' item ID]] for the item which acts as a machine (like <samp>(BC)127</samp> for [[The Cave|mushroom boxes]]).
  −
* The value is a model with the fields listed below.
     −
====Item processing rules====
+
For C# mods, 1.6 also adds a new <samp>MachineDataUtility</samp> class and various <samp>Object</samp> to simplify working with machines in code. These are used by the game code itself to implement the base machine logic.
{| class="wikitable"
  −
|-
  −
! field
  −
! effect
  −
|-
  −
| <samp>OutputRules</samp>
  −
| The output produced by this machine. If multiple output rules can be produced, the first available one is selected. This consists 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 rule within the current machine (it doesn't need to be unique between machines).
  −
|-
  −
| <samp>Triggers</samp>
  −
| When to apply this output rule. This can list any number of triggers; the output will apply if any of them match.
  −
 
  −
This consists 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 trigger within the current rule.
  −
|-
  −
| <samp>Trigger</samp>
  −
| ''(Optional)'' When this output rule applies. Defaults to <samp>ItemPlacedInMachine</samp>. The possible values are...
  −
* <samp>ItemPlacedInMachine</samp>: apply this rule when an item is placed into the machine. This is the most common machine behavior.
  −
* <samp>OutputCollected</samp>: apply this rule when the machine's previous output is collected. An output-collected rule won't require or consume the input items, and the input item will be the previous output. For example, this is used to reload the [[crystalarium]].
  −
* <samp>MachinePutDown</samp>: apply this rule when the machine is put down. For example, this is used to start the [[Worm Bin|worm bin]].
  −
* <samp>DayUpdate</samp>: apply this rule when a new day starts, if it isn't already processing output. For example, this is used for the [[Soda Machine|soda machine]].
  −
 
  −
You can specify multiple values, like <code>"Trigger": "DayUpdate, MachinePutDown, OutputCollected"</code>.
  −
|-
  −
| <samp>RequiredItemId</samp>
  −
| ''(Optional)'' The qualified or unqualified item ID for the item to match, if the trigger is <samp>ItemPlacedInMachine</samp> or <samp>OutputCollected</samp>. Defaults to allowing any item ID.
  −
|-
  −
| <samp>RequiredTags</samp>
  −
| ''(Optional)'' The [[Modding:Context tags|context tags]] to match against input items, if the trigger is <samp>ItemPlacedInMachine</samp> or <samp>OutputCollected</samp>. An item must have all of the listed tags to select this rule. You can negate a tag with <samp>!</samp> (like <code>"RequiredTags": [ "bone_item", "!fossil_item" ]</code> for bone items that aren't fossils).
  −
|-
  −
| <samp>RequiredCount</samp>
  −
| ''(Optional)'' The required stack size for the input item, if the trigger is <samp>ItemPlacedInMachine</samp> or <samp>OutputCollected</samp>. Default 1.
  −
|-
  −
| <samp>Condition</samp>
  −
| ''(Optional)'' A [[Modding:Game state queries|game state query]] which indicates whether this trigger should be checked. Item-only tokens are valid for this check if the trigger is <samp>ItemPlacedInMachine</samp> or <samp>OutputCollected</samp>. Defaults to always true.
  −
|}
  −
|-
  −
| <samp>OutputItem</samp>
  −
| The items produced by this machine. If multiple output entries match, one will be selected randomly unless you specify <samp>UseFirstValidOutput</samp>. This consists of a list of models with these fields:
  −
{| class="wikitable"
  −
|-
  −
! field
  −
! effect
  −
|-
  −
| ''common fields''
  −
| See [[Modding:Item queries#Item spawn fields|item spawn fields]] for the generic item fields supported by machine output.
  −
 
  −
Notes:
  −
<ul>
  −
<li>If <samp>ItemId</samp> or <samp>RandomItemId</samp> is set to an [[Modding:Item queries|item query]] which returns multiple items, one item will be selected at random.</li>
  −
<li>The <samp>ItemId</samp> and <samp>RandomItemId</samp> can optionally contain special tokens, which will be replaced before the item ID is parsed. For example, you can use <code>FLAVORED_ITEM Wine DROP_IN_ID</code> to create a wine for whatever item was placed in the machine.
  −
{| class="wikitable"
  −
|-
  −
! token
  −
! replaced with
  −
|-
  −
| <samp>DROP_IN_ID</samp>
  −
| The qualified item ID for the item placed in the machine.
  −
|-
  −
| <samp>DROP_IN_PRESERVE</samp>
  −
| If the item placed into the machine is a flavored item like Apple Juice or Tuna Roe, the ''unqualified'' item ID for the flavor item (e.g. the apple in Apple Wine). Otherwise <samp>0</samp>.
  −
|-
  −
| <samp>NEARBY_FLOWER_ID</samp>
  −
| The item ID for a flower within 5 tiles of the machine, or <samp>-1</samp> if no flower is found. For example, [[Bee House|bee houses]] produce <code>FLAVORED_ITEM Honey NEARBY_FLOWER_ID</code>.
  −
|}
  −
</li>
  −
<li>The <samp>ObjectInternalName</samp> can optionally contain <samp>{0}</samp>, which will be replaced with the input item's internal name. This is used to prevent flavored items from stacking (''e.g.'' apple [[wine]] and blueberry wine).</li>
  −
<li>The <samp>Condition</samp> field will check the ''input'' (not output) item for item-related conditions.</li>
  −
</ul>
  −
|-
  −
| <samp>PreserveType</samp>
  −
| ''(Optional)'' The produced item's preserved item type, if applicable. This sets the equivalent flag on the output item. The valid values are <samp>Jelly</samp>, <samp>Juice</samp>, <samp>Pickle</samp>, <samp>Roe</samp> or <samp>AgedRoe</samp>, and <samp>Wine</samp>. Defaults to none.
  −
|-
  −
| <samp>PreserveId</samp>
  −
| ''(Optional)'' The produced item's preserved unqualified item ID, if applicable. For example, [[Wine|blueberry wine]] has its preserved item ID set to the [[blueberry]] ID. This can be set to <samp>DROP_IN</samp> to use the input item's ID. Default none.
  −
|-
  −
| <samp>CopyColor</samp>
  −
| ''(Optional)'' Whether to inherit the color of the input item if it was a <samp>ColoredObject</samp>. This mainly affects [[roe]]. Default false.
  −
|-
  −
| <samp>CopyPrice</samp>
  −
| ''(Optional)'' Whether to inherit the quality of the input item (before <samp>PriceModifiers</samp> are applied). This is ignored if the input or output aren't both object (<samp>(O)</samp>)-type.
  −
|-
  −
| <samp>CopyQuality</samp>
  −
| ''(Optional)'' Whether to inherit the quality of the input item (before <samp>QualityModifiers</samp> are applied).
  −
|-
  −
| <samp>PriceModifiers</samp><br /><samp>PriceModifiers</samp>
  −
| ''(Optional)'' [[#Quantity modifiers|Quantity modifiers]] applied to the output item's price. Default none.
  −
|-
  −
| <samp>IncrementMachineParentSheetIndex</samp>
  −
| ''(Optional)'' An amount by which to increment the machine's spritesheet index while it's processing this output. This stacks with the <samp>ShowNextIndexWhenLoaded</samp> or <samp>ShowNextIndexWhileWorking</samp> field. Default 0.
  −
|-
  −
| <samp>OutputMethod</samp>
  −
| ''(Optional, specialized)'' A C# method which decides which item to produce. If set, the <samp>ItemId</samp> field is optional and ignored.
  −
 
  −
This must be specified in the form <samp>{{t|full type name}}: {{t|method name}}</samp> (like <samp>StardewValley.Object, Stardew Valley: OutputSolarPanel</samp>). The method must be static and match the game's <samp>MachineOutputDelegate</samp> method signature:
  −
<syntaxhighlight lang="c#">
  −
/// <summary>Get the output item to produce.</summary>
  −
/// <param name="machine">The machine instance for which to produce output.</param>
  −
/// <param name="inputItem">The item being dropped into the machine, if applicable.</param>
  −
/// <param name="probe">Whether the machine is only checking whether the input is valid. If so, the input/machine shouldn't be changed and no animations/sounds should play.</param>
  −
/// <param name="outputData">The item output data from <c>Data/Machines</c> for which output is being created, if applicable.</param>
  −
/// <param name="overrideMinutesUntilReady">The in-game minutes until the item will be ready to collect, if set. This overrides the equivalent fields in the machine data if set.</param>
  −
/// <returns>Returns the item to produce, or <c>null</c> if none should be produced.</returns>
  −
public static Item GetOutput(Object machine, Item inputItem, bool probe, MachineItemOutput outputData, out int? overrideMinutesUntilReady);
  −
</syntaxhighlight>
  −
 
  −
If this method returns null, the machine won't output anything.
  −
|-
  −
| <samp>CustomData</samp>
  −
| Machine-specific data provided to the machine logic, if applicable.
  −
 
  −
For example, the cask uses this to set the aging rate for each item:
  −
<syntaxhighlight lang="js">
  −
"OutputItem": {
  −
    "OutputMethod": "StardewValley.Objects.Cask, Stardew Valley: OutputCask",
  −
    "CustomData": {
  −
        "AgingMultiplier": 4
  −
    }
  −
}
  −
</syntaxhighlight>
  −
|}
  −
|-
  −
| <samp>UseFirstValidOutput</samp>
  −
| ''(Optional)'' If multiple <samp>OutputItem</samp> entries match, whether to use the first match instead of choosing one randomly. Default false.
  −
|-
  −
| <samp>MinutesUntilReady</samp><br /><samp>DaysUntilReady</samp>
  −
| ''(Optional)'' The number of in-game minutes or days until the output is ready to collect. If both days and minutes are specified, days are used. If none are specified, the item will be ready instantly.
  −
|-
  −
| <samp>InvalidCountMessage</samp>
  −
| ''(Optional)'' If set, overrides the machine's main <samp>InvalidCountMessage</samp> field.
  −
|-
  −
| <samp>RecalculateOnCollect</samp>
  −
| ''(Optional)'' Whether to regenerate the output right before the player collects it, similar to [[Bee House|bee houses]]. If the new item is null, the original output is returned instead.
  −
|}
  −
|-
  −
| <samp>AdditionalConsumedItems</samp>
  −
| ''(Optional)'' A list of extra items required before <samp>OutputRules</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>ItemId</samp>. Default 1.
  −
|-
  −
| <samp>InvalidCountMessage</samp>
  −
| ''(Optional)'' If set, overrides the machine's main <samp>InvalidCountMessage</samp> field.
  −
|}
  −
|-
  −
| <samp>AllowFairyDust</samp>
  −
| ''(Optional)'' Whether the player can add [[Fairy Dust|fairy dust]] to speed up the machine. Default true.
  −
|-
  −
| <samp>ReadyTimeModifiers</samp>
  −
| ''(Optional)'' [[#Quantity modifiers|Quantity modifiers]] applied to the produced item's processing time. The modifier conditions can use item-only tokens, which will check the ''input'' (not output) item.
  −
|-
  −
| <samp>ReadyTimeModifierMode</samp>
  −
| ''(Optional)'' A [[#Quantity modifiers|quantity modifier mode]] which indicates what to do if multiple modifiers apply at the same time. Default <samp>Stack</samp>.
  −
|}
  −
 
  −
====Behavior tweaks====
  −
{| class="wikitable"
  −
|-
  −
! field
  −
! effect
  −
|-
  −
| <samp>PreventTimePass</samp>
  −
| ''(Optional)'' A list of cases when the machine should be paused, so the timer on any item being produced doesn't decrement. Possible values:
  −
{| class="wikitable"
  −
|-
  −
! value
  −
! effect
  −
|-
  −
| <samp>Outside</samp><br /><samp>Inside</samp>
  −
| Pause when placed in an outside or inside location. For example, [[Bee House|bee houses]] don't work inside.
  −
|-
  −
| <samp>Spring</samp><br /><samp>Summer</samp><br /><samp>Fall</samp><br /><samp>Winter</samp>
  −
| Pause in the given season. For example, [[Bee House|bee houses]] don't work in winter.
  −
|-
  −
|-
  −
| <samp>Sun</samp><br /><samp>Rain</samp>
  −
| Pause on days with the given weather.
  −
|-
  −
| <samp>Always</samp>
  −
| Always pause the machine. This is used in specialized cases where the timer is handled by [[#Advanced logic|advanced machine logic]].
  −
|}
  −
|-
  −
| <samp>AllowLoadWhenFull</samp>
  −
| ''(Optional)'' Whether the player can drop a new item into the machine before it's done processing the last one (like the [[crystalarium]]). The previous item will be lost. Default false.
  −
|-
  −
| <samp>ClearContentsOvernightCondition</samp>
  −
| ''(Optional)'' A [[Modding:Game state queries|game state query]] which indicates whether the machine should be emptied overnight, so any current output will be lost. Defaults to always false.
  −
|}
  −
 
  −
====Audio & visuals====
  −
{| class="wikitable"
  −
|-
  −
! field
  −
! effect
  −
|-
  −
| <samp>LoadEffects</samp><br /><samp>WorkingEffects</samp>
  −
| ''(Optional)'' The cosmetic effects shown when an item is loaded into the machine (for <samp>LoadEffects</samp>), or while it's processing the item (for <samp>WorkingEffects</samp>, based on the <samp>WorkingEffectChance</samp> probability). Both default to none. These consist of a list of models with these fields:
  −
{| class="wikitable"
  −
|-
  −
! field
  −
! effect
  −
|-
  −
| <samp>Condition</samp>
  −
| ''(Optional)'' A [[Modding:Game state queries|game state query]] which indicates whether this effect should be played. For item queries, you can check the input item (<samp>Input</samp) or output item (<samp>Target</samp>). Defaults to always true.
  −
|-
  −
| <samp>Sounds</samp>
  −
| ''(Optional)'' The audio to play. This consists of a list of models with these fields:
  −
{| class="wikitable"
  −
|-
  −
! field
  −
! effect
  −
|-
  −
| <samp>Id</samp>
  −
| The [[#Custom audio|audio cue ID]] to play.
  −
|-
  −
| <samp>Delay</samp>
  −
| ''(Optional)'' The number of milliseconds until the sound should play. Default 0.
  −
|}
  −
 
  −
Defaults to no sound.
  −
|-
  −
| <samp>ShakeDuration</samp>
  −
| ''(Optional)'' A duration in milliseconds during which the machine sprite should shake. Default none.
  −
|-
  −
| <samp>Frames</samp>
  −
| ''(Optional)'' The animation to apply to the machine sprite, specified as a list of offsets relative to the base sprite index. Default none.
  −
|-
  −
| <samp>Interval</samp>
  −
| ''(Optional)'' The number of milliseconds for which each frame in <samp>Frames</samp> is kept on-screen. Default 100.
  −
|-
  −
| <samp>TemporarySprites</samp>
  −
| ''(Optional)'' The temporary animated sprites to show. This consists 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 rule within the current machine (it doesn't need to be unique between machines).
  −
|-
  −
| <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>Condition</samp>
  −
| ''(Optional)'' A [[Modding:Game state queries|game state query]] which indicates whether to add this temporary sprite.
  −
|-
  −
| <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>Color</samp>
  −
| ''(Optional)'' A tint color to apply to the sprite. See [[#Color fields|color format]]. Default <samp>White</samp> (no tint).
  −
|-
  −
| <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 [[#Event changes|<samp>temporaryAnimatedSprite</samp> event command]]. Default 0.
  −
|-
  −
| <samp>Frames</samp><br /><samp>Scale</samp>
  −
| ''(Optional)'' See equivalent fields in the [[#Event changes|<samp>temporaryAnimatedSprite</samp> event command]]. Default 1.
  −
|-
  −
| <samp>Interval</samp>
  −
| ''(Optional)'' See equivalent fields in the [[#Event changes|<samp>temporaryAnimatedSprite</samp> event command]]. Default 100.
  −
|-
  −
| <samp>Flicker</samp><br /><samp>Flip</samp>
  −
| ''(Optional)'' See equivalent fields in the [[#Event changes|<samp>temporaryAnimatedSprite</samp> event command]]. Default false.
  −
|}
  −
|}
  −
|-
  −
| <samp>WorkingEffectChance</samp>
  −
| ''(Optional)'' The percentage chance to apply <samp>WorkingEffects</samp> each time the day starts or the in-game clock changes, as a value between 0 (never) and 1 (always). Default 0.33.
  −
|-
  −
| <samp>LightWhileWorking</samp>
  −
| ''(Optional)'' The light emitted by the machine while it's processing an item. Default none.
  −
 
  −
This consists of a list of models with these fields:
  −
{| class="wikitable"
  −
|-
  −
! field
  −
! effect
  −
|-
  −
| <samp>Radius</samp>
  −
| ''(Optional)'' The size of the area covered by the light effect, as a multiplier of the default radius (like <samp>1.5</samp> for an area 50% wider than the default). Default 1.
  −
|-
  −
| <samp>Color</samp>
  −
| ''(Optional)'' A tint color to apply to the light. See [[#Color fields|color format]]. Default <samp>White</samp> (no tint).
  −
|}
  −
|-
  −
| <samp>WobbleWhileWorking</samp>
  −
| ''(Optional)'' Whether the machine sprite should bulge in & out while it's processing an item. Default false.
  −
|-
  −
| <samp>ShowNextIndexWhileWorking</samp><br /><samp>ShowNextIndexWhenReady</samp>
  −
| ''(Optional)'' Whether to show the next sprite in the machine's spritesheet while it's processing an item (<samp>ShowNextIndexWhileWorking</samp>) or ready (<samp>ShowNextIndexWhenReady</samp>). Default false.
  −
|}
  −
 
  −
====Player interaction messages====
  −
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 [[Modding:Tokenizable strings|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>InvalidItemMessageCondition</samp>
  −
| ''(Optional)'' A [[Modding:Game state queries|game state query]] which indicates whether <samp>InvalidItemMessage</samp> should be shown. This can use item-related queries like <samp>ITEM_TYPE</samp>. Defaults to always true.
  −
|-
  −
| <samp>InvalidCountMessage</samp>
  −
| ''(Optional)'' A [[Modding:Tokenizable strings|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>OutputRules</samp>.
  −
 
  −
This can use extra custom tokens:
  −
* <samp>[ItemCount]</samp>: the number of remaining items needed. For example, if you're holding three and need five, <samp>[ItemCount]</samp> will be replaced with <samp>2</samp>.
  −
|}
  −
 
  −
====Advanced logic====
  −
{| class="wikitable"
  −
|-
  −
! field
  −
! effect
  −
|-
  −
| <samp>InteractMethod</samp>
  −
| ''(Optional)'' A C# method invoked when the player interacts with the machine when it doesn't have output ready to harvest.
  −
 
  −
This must be specified in the form <samp>{{t|full type name}}: {{t|method name}}</samp> (like <samp>StardewValley.Object, Stardew Valley: SomeInteractMethod</samp>). The method must be static and match the game's <samp>MachineInteractDelegate</samp> method signature:
  −
<syntaxhighlight lang="c#">
  −
/// <summary>The method signature for a custom <see cref="MachineData.InteractMethod"/> method.</summary>
  −
/// <param name="machine">The machine instance for which to produce output.</param>
  −
/// <param name="location">The location containing the machine.</param>
  −
/// <param name="player">The player using the machine.</param>
  −
/// <returns>Returns whether the interaction was handled.</returns>
  −
public static bool InteractWithMachine(Object machine, GameLocation location, Farmer player);
  −
</syntaxhighlight>
  −
|-
  −
| <samp>HasInput</samp><br /><samp>HasOutput</samp>
  −
| ''(Optional)'' Whether to force adding the <samp>machine_input</samp> or <samp>machine_output</samp> [[#New context tags|context tags]] respectively. This isn't needed for most machines, since they'll be set based on the <samp>OutputRules</samp> field. Default false.
  −
|-
  −
| <samp>IsIncubator</samp>
  −
| ''(Optional)'' Whether this machine acts as an incubator when placed in a building, so players can incubate eggs in it. Default false.
  −
 
  −
This is used by the [[incubator]] and [[Ostrich Incubator|ostrich incubator]]. The game logic assumes there's only one such machine in each building, so this generally shouldn't be used by custom machines that can be built in a vanilla [[barn]] or [[coop]].
  −
|-
  −
| <samp>StatsToIncrementWhenLoaded</samp><br /><samp>StatsToIncrementWhenHarvested</samp>
  −
| ''(Optional)'' The game stat counters to increment when an item is placed in the machine (<samp>StatsToIncrementWhenLoaded</samp>) or when the processed output is collected (<samp>StatsToIncrementWhenHarvested</samp>). Default none. This consists of a list of models with these fields:
  −
{| class="wikitable"
  −
|-
  −
! field
  −
! effect
  −
|-
  −
| <samp>StatName</samp>
  −
| The name of the stat counter field in <samp>Game1.stats</samp>. Stat names are case-insensitive.
  −
|-
  −
| <samp>RequiredItemId</samp>
  −
| ''(Optional)'' If set, only increment the stat if the main input item has this qualified or unqualified item ID.
  −
|-
  −
| <samp>RequiredTags</samp>
  −
| ''(Optional)'' If set, only increment the stat if the main input item has ''all'' of these [[Modding:Context tags|context tags]]. You can negate a tag with <samp>!</samp> (like <code>"RequiredTags": [ "bone_item", "!fossil_item" ]</code> for bone items that aren't fossils).
  −
|}
  −
 
  −
This can be used to increment both built-in stats (like <samp>GeodesCracked</samp> for the [[Geode Crusher|geode crusher]]) and custom stats. Using a [[Modding:Common data field types#Unique string ID|unique string ID]] is strongly recommended for custom stats to avoid conflicts.
  −
|-
  −
| <samp>CustomFields</samp>
  −
| The [[#Custom data fields|custom fields]] for this entry.
  −
|}
  −
 
  −
====Interacting with machines in C#====
  −
Stardew Valley 1.6 adds two <samp>Object</samp> fields for reference:
  −
{| class="wikitable"
  −
|-
  −
! field
  −
! effect
  −
|-
  −
| <samp>lastOutputRuleId</samp>
  −
| If this is a machine, the output rule ID for the rule being processed by the machine (if any).
  −
|-
  −
| <samp>lastInputItem</samp>
  −
| If this is a machine, the item that was dropped into the machine to start the current output (if any).
  −
|}
  −
 
  −
And a few methods for processing items:
  −
{| class="wikitable"
  −
|-
  −
! field
  −
! effect
  −
|-
  −
| <samp>IsMachineWorking()</samp>
  −
| Get whether the machine is currently processing an item.
  −
|-
  −
| <samp>ShouldTimePassForMachine(location)</samp>
  −
| Get whether the machine should be updated in the given location. For example, this will return false for [[Solar Panel|solar panels]] placed indoors, or outdoors on a cloudy day.
  −
|-
  −
| <samp>GetMachineData()</samp>
  −
| Get the underlying machine data from <samp>Data/Machines</samp>.
  −
|-
  −
| <samp>PlaceInMachine(…)</samp>
  −
| Try to place an item in the machine using the rules from <samp>Data/Machines</samp>. This returns a boolean which indicates whether the machine was successfully started.
  −
|-
  −
| <samp>OutputMachine(…)</samp>
  −
| Try to set the machine output given the input item and an optional output rule to apply. Most code should call <samp>PlaceInMachine</samp> instead.
  −
|}
  −
 
  −
A lot of the generic machine logic is also handled by a new <samp>MachineDataUtility</samp> class, which lets C# mods interact with machine data more directly. For example, you can check which output a machine would produce without actually updating the machine.
      
===Custom melee weapons===
 
===Custom melee weapons===
translators
8,403

edits

Navigation menu