### Ensure Different Outfits with Pinned Keys (JavaScript) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/tokens.md This example uses the same pinned key 'outfit' for two different NPCs but with different lists of available outfits. This setup ensures that while each NPC gets a random outfit, they will never wear the same one because the internal random number is synced, but the mapping to the outfit differs. ```javascript { "Action": "Load", "Target": "Characters/Abigail, Portraits/Abigail", "FromFile": "assets/{{Target}}-{{Random:hood, jacket, raincoat |key=outfit}}.png" }, { "Action": "Load", "Target": "Characters/Haley, Portraits/Haley", "FromFile": "assets/{{Target}}-{{Random:jacket, raincoat, hood |key=outfit}}.png" } ``` -------------------------------- ### Content Patcher Load Action Example (v2.1.0+) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-migration-guide.md Example of a 'Load' action in Content Patcher. Starting with format version 2.1.0, 'Load' patches apply to localized asset names only if they have localized forms in the base game folder. This example demonstrates loading 'Characters/Toddler'. ```json { "Action": "Load", "Target": "Characters/Toddler", "FromFile": "assets/toddler.png" } ``` -------------------------------- ### Uppercase Token Example Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/tokens.md Demonstrates the 'Uppercase' token, which converts its input to uppercase. This is an example of how tokens can change their output based on input arguments. ```json "Entries": { "fri": "It's a beautiful {{uppercase: {{season}}}} day!" // It's a beautiful SPRING day! } ``` -------------------------------- ### Content Pack Structure Example Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide.md Illustrates the typical file and folder structure for a Content Patcher content pack. It includes the essential `content.json` and `manifest.json` files, along with an `assets` folder for custom files. ```tree 📁 Mods/ 📁 [CP] YourModName/ 🗎 content.json 🗎 manifest.json 📁 assets/ 🗎 example.png ``` -------------------------------- ### Translation File Example (default.json) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/translations.md An example of a default translation file (i18n/default.json) containing key-value pairs for item names and descriptions. This file serves as the fallback if translations for other languages are not available. ```json { "item.name": "Pufferchick", "item.description": "A tiny hybrid between a pufferfish and chicken." } ``` -------------------------------- ### Access Data Layers API in C# Source: https://github.com/pathoschild/stardewmods/blob/develop/DataLayers/docs/author-guide.md Demonstrates how to get the IDataLayersApi instance from the mod registry within the GameLaunched event. This is the first step to integrating custom data layers. It checks if the Data Layers mod is installed before proceeding. ```csharp var dataLayers = this.Helper.ModRegistry.GetApi("Pathoschild.DataLayers"); if (dataLayers is null) return; // Data Layers not installed ``` -------------------------------- ### Group Config Options into Sections Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/config.md Shows how to organize configuration options into visual sections within the in-game UI using the Section field in the ConfigSchema. ```json { "Format": "2.9.0", "ConfigSchema": { "Material": { "AllowValues": "Wood, Metal", "Default": "Wood", "Section": "Appearance" }, "Texture": { "AllowValues": "Grainy, Smooth", "Default": "Grainy", "Section": "Appearance" }, "Enabled": { "AllowValues": "true, false", "Default": "true", "Section": "Behavior" } }, "Changes": [ ] } ``` -------------------------------- ### ValueAt Argument Example (Table) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/tokens.md Demonstrates the 'valueAt' global input argument for retrieving a specific value from a token's list by its index. Supports positive and negative indexing. ```plaintext
token value
{{ChildNames}} Angus, Bob, Carrie
{{ChildNames |valueAt=0}} Angus
{{ChildNames |valueAt=1}} Bob
{{ChildNames |valueAt=2}} Carrie
{{ChildNames |valueAt=3}} empty list
token value
{{ChildNames |valueAt=-1}} Carrie
{{ChildNames |valueAt=-2}} Bob
{{ChildNames |valueAt=-3}} Angus
{{ChildNames |valueAt=-4}} empty list
``` -------------------------------- ### Translation File Example (fr.json) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/translations.md An example of a French translation file (i18n/fr.json) providing localized text for item names and descriptions. This demonstrates how to override default translations for specific languages. ```json { "item.name": "Poussin-globe", "item.description": "Un tout petit hybride entre un poisson-globe et un poussin." } ``` -------------------------------- ### Custom Patch Update Rate (JSON) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide.md Shows how to configure a Content Patcher patch to update more frequently than the default 'OnDayStart'. This example uses 'OnTimeChange' to reapply the patch whenever the in-game time changes. ```json { "Action": "EditMap", "Target": "Maps/Town", "SetProperties": { "CurrentTime": "{{Time}}" }, "Update": "OnTimeChange" } ``` -------------------------------- ### Custom Input Separator Example (JSON) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/tokens.md Shows how to use the 'inputSeparator' argument to define a custom delimiter for input values, allowing commas or other special characters within the values themselves. ```json "Entries": { "fri": "{{Random: Hey, how are you? @@ Hey, what's up? |inputSeparator=@@}}" } ``` -------------------------------- ### Edit Dictionary Data Asset Example (JSON) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/action-editdata.md This example demonstrates how to edit a dictionary data asset, such as Data/Boots. Dictionaries are key/value pairs enclosed in curly braces. This patch targets the 'Data/Boots' asset and modifies the entry with key '504'. ```json { "Action": "EditData", "Target": "Data/Boots", "Entries": { "504": "Sneakers/A little flimsy... but fashionable!/50/1/0/0/Sneakers" } } ``` -------------------------------- ### Edit List Data Asset Example (JSON) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/action-editdata.md This example shows how to edit a list data asset, like Data/Concessions. Lists are non-unique sets of values enclosed in square brackets. This patch targets the 'Data/Concessions' asset and adds a new entry to the list. ```json { "Action": "EditData", "Target": "Data/Concessions", "Entries": [ { "ID": 10, "Name": "New Item", "DisplayName": "A New Treat", "Description": "Tastes great!", "Price": 100, "ItemTags": [ "Food", "Sweet" ] } ] } ``` -------------------------------- ### Include Action in JSON Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide.md The 'Include' action allows organizing content packs by loading patches from other JSON files. This is useful for modularity and can be combined with tokens for dynamic loading. This example includes a JSON file based on the current season. ```json { "Format": "2.9.0", "Changes": [ { "Action": "Include", "FromFile": "assets/john_{{season}}.json" } ] } ``` -------------------------------- ### Generated config.json output Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/config.md The resulting configuration file automatically generated by Content Patcher based on the defined ConfigSchema. ```json { "Material": "Wood" } ``` -------------------------------- ### Define Mod Configuration Schema Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide.md Shows how to define a ConfigSchema to allow players to toggle mod features. The defined config values can then be used as tokens within the patch conditions. ```json { "Format": "2.9.0", "ConfigSchema": { "EnableJohn": { "AllowValues": "true, false", "Default": true } }, "Changes": [ { "Action": "Include", "FromFile": "assets/john.json", "When": { "EnableJohn": true } } ] } ``` -------------------------------- ### Overlay Map Example (JSON) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/action-editmap.md This JSON snippet demonstrates how to overlay a section of one map onto another. It specifies the target map, the source map file, and the areas to copy from and to. The 'FromFile' field indicates the source map, and 'FromArea' and 'ToArea' define the specific regions for the overlay operation. ```json { "Format": "2.9.0", "Changes": [ { "Action": "EditMap", "Target": "Maps/Town", "FromFile": "assets/town.tmx", "FromArea": { "X": 22, "Y": 61, "Width": 16, "Height": 13 }, "ToArea": { "X": 22, "Y": 61, "Width": 16, "Height": 13 } } ] } ``` -------------------------------- ### Batch Load Multiple Assets Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/action-load.md Shows how to define multiple 'Load' patches within a single 'Changes' array to replace several game assets simultaneously. ```json { "Format": "2.9.0", "Changes": [ { "Action": "Load", "Target": "Portraits/Abigail", "FromFile": "assets/abigail.png" }, { "Action": "Load", "Target": "Portraits/Penny", "FromFile": "assets/penny.png" } ] } ``` -------------------------------- ### Random Token Synchronization Example (Text) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/tokens.md Illustrates how random tokens behave without and with pinned keys. Without keys, each token chooses independently. With the same key, all tokens use the same internal random number, leading to synchronized choices. ```text {{Random: hood, jacket, raincoat}} {{Random: hood, jacket, raincoat}} {{Random: hood, jacket, raincoat}} ``` ```text {{Random: hood, jacket, raincoat |key=outfit}} {{Random: hood, jacket, raincoat |key=outfit}} {{Random: hood, jacket, raincoat |key=outfit}} ``` -------------------------------- ### Edit Target Field Example (JSON) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/action-editdata.md This example demonstrates how to use a target field to modify a specific sub-block within a data asset. Here, the patch targets the 'ContextTags' field of the 'MossSoup' entry in 'Data/Objects', allowing direct manipulation of the tags. ```json { "Action": "EditData", "Target": "Data/Objects/MossSoup/ContextTags", "Entries": [ "color_green", "food" ] } ``` -------------------------------- ### Implement IAutomationFactory to register machines Source: https://github.com/pathoschild/stardewmods/blob/develop/Automate/docs/technical.md Creates a factory class that implements IAutomationFactory to detect specific in-game objects and return the corresponding IMachine instance for automation. ```c# using Microsoft.Xna.Framework; using StardewValley; namespace YourModName { public class MyAutomationFactory : IAutomationFactory { public IAutomatable GetFor(SObject obj, GameLocation location, in Vector2 tile) { if (obj.QualifiedItemId == "(BC)Example.ModId_Transmuter") return new TransmuterMachine(obj, location, tile); return null; } } } ``` -------------------------------- ### Restrict Tourist Spawn Areas Source: https://github.com/pathoschild/stardewmods/blob/develop/CentralStation/docs/author-guide.md Example of the 'OnlyInAreas' configuration field to limit where a specific tourist NPC can spawn within the Central Station. ```json "Areas": [ "FoodCout", "GiftShop" ] ``` -------------------------------- ### Accessing the Automate API in C# Source: https://github.com/pathoschild/stardewmods/blob/develop/Automate/docs/technical.md Demonstrates how to retrieve the IAutomateAPI instance from the SMAPI ModRegistry. This allows modders to extend Automate functionality by registering custom machines or containers. ```csharp IAutomateAPI automate = this.Helper.ModRegistry.GetApi("Pathoschild.Automate"); ``` -------------------------------- ### Define Content Patcher ConfigSchema Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/config.md Demonstrates how to define a ConfigSchema in content.json to create user-editable settings. It shows both the schema definition and how to apply those settings as tokens or conditions within the Changes array. ```json { "Format": "2.9.0", "ConfigSchema": { "Material": { "AllowValues": "Wood, Metal", "Default": "Wood" } }, "Changes": [ { "Action": "Load", "Target": "LooseSprites/Billboard", "FromFile": "assets/material_{{Material}}.png" }, { "Action": "Load", "Target": "LooseSprites/Billboard", "FromFile": "assets/material_wood.png", "When": { "Material": "Wood" } } ] } ``` -------------------------------- ### Edit Model Data Asset Example (JSON) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/action-editdata.md This example illustrates editing a model data asset. Models are predefined data structures, similar to dictionaries but without the ability to add new entries. This patch targets a specific entry within a model asset and modifies one of its fields. ```json { "Action": "EditData", "Target": "Data/Objects", "Entries": { "MossSoup": { "Price": 100, "ContextTags": [ "color_green", "food" ] } } } ``` -------------------------------- ### Default Patch Application (JSON) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide.md Demonstrates the default behavior of a Content Patcher patch where fields are updated when the in-game day starts. This patch targets the 'Maps/Town' asset and sets the 'CurrentTime' property. ```json { "Action": "EditMap", "Target": "Maps/Town", "SetProperties": { "CurrentTime": "{{Time}}" } } ``` -------------------------------- ### Implement Include action in content.json Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/action-include.md Examples of using the 'Include' action within a main content.json file. This includes basic file inclusion and dynamic loading using tokens and conditional logic. ```json { "Format": "2.9.0", "Changes": [ { "Action": "Include", "FromFile": "assets/John NPC.json, assets/Jane NPC.json" } ] } ``` ```json { "Format": "2.9.0", "Changes": [ { "Action": "Include", "FromFile": "assets/John_{{season}}.json", "When": { "EnableJohn": true } } ] } ``` -------------------------------- ### Configurable Mod Options - SMAPI Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/tokens.md Demonstrates how to use configuration values from a 'config.json' file as tokens and conditions within a mod. This allows players to customize mod behavior, with options for an in-game menu if Generic Mod Config Menu is installed. ```json { "Format": "2.9.0", "ConfigSchema": { "EnableJohn": { "AllowValues": "true, false", "Default": true } }, "Changes": [ { "Action": "Include', "FromFile": "assets/john.json", "When": { "EnableJohn": true } } ] } ``` -------------------------------- ### Targeting Specific Language (JSON) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide.md Illustrates how to apply a Content Patcher patch to a specific language version of an asset. This example uses the 'When' condition to target German ('de') language files for the 'LooseSprites/Cursors' asset. ```json { "Action": "EditImage", "Target": "LooseSprites/Cursors", "FromFile": "assets/cursors.de.png", "When": { "Language": "de" } } ``` -------------------------------- ### Define Custom Location and Map Edits Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/custom-locations.md Demonstrates how to register a new location using a TMX file and apply map edits such as adding warps and conditional content changes. ```json { "Format": "2.9.0", "CustomLocations": [ { "Name": "{{ModId}}_AbigailCloset", "FromMapFile": "assets/abigail-closet.tmx" } ], "Changes": [ { "Action": "EditMap", "Target": "Maps/SeedShop", "AddWarps": [ "8 10 {{ModId}}_AbigailCloset 7 20" ] }, { "Action": "EditMap", "Target": "Maps/{{ModId}}_AbigailCloset", "FromFile": "assets/abigail-closet-clean.tmx", "When": { "HasFlag": "AbigailClosetClean" } } ] } ``` -------------------------------- ### Implement Custom Machine Factory for Automate (C#) Source: https://github.com/pathoschild/stardewmods/blob/develop/Automate/docs/technical.md Implement the IAutomatable interface to create custom machines that Automate can manage. The GetFor methods allow Automate to detect your machine on terrain features, buildings, or specific tiles. Ensure your factory is registered with the Automate API. ```csharp /// Get a machine, container, or connector instance for a given terrain feature. /// The terrain feature. /// The location to check. /// The tile position to check. /// Returns an instance or null. public IAutomatable GetFor(TerrainFeature feature, GameLocation location, in Vector2 tile) { return null; } /// Get a machine, container, or connector instance for a given building. /// The building. /// The location to check. /// The tile position to check. /// Returns an instance or null. public IAutomatable GetFor(Building building, GameLocation location, in Vector2 tile) { return null; } /// Get a machine, container, or connector instance for a given tile position. /// The location to check. /// The tile position to check. /// Returns an instance or null. /// Shipping bin logic from , garbage can logic from . public IAutomatable GetForTile(GameLocation location, in Vector2 tile) { return null; } ``` ```csharp IAutomateAPI automate = ...;automate.AddFactory(new MyAutomationFactory()); ``` -------------------------------- ### Using i18n Token with Custom Arguments Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/translations.md Shows how to pass custom arguments to the i18n token to populate placeholders within translation strings. This example demonstrates providing values for 'day' and 'name' tokens in a dialogue translation. ```json "{{i18n: dialogue |day={{DayOfWeek}} |name=Abigail }}" ``` -------------------------------- ### Implement Dynamic Content Changes with Tokens and Conditions Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide.md Demonstrates how to use Content Patcher tokens to load assets based on game state, such as current season or player relationship status. These changes allow for dynamic asset replacement without hardcoding values. ```json { "Format": "2.9.0", "Changes": [ { "Action": "Load", "Target": "Portraits/Abigail", "FromFile": "assets/abigail-{{season}}.png" } ] } ``` ```json { "Format": "2.9.0", "Changes": [ { "Action": "Load", "Target": "Portraits/Abigail", "FromFile": "assets/abigail-married.png", "When": { "Spouse": "Abigail" } } ] } ``` -------------------------------- ### EditImage Action in JSON Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide.md The 'EditImage' action modifies parts of game image assets. It supports replacing portions, overlaying new images with transparency, or extending image dimensions. This example replaces a specific area of the 'springobjects' image with a custom sprite. ```json { "Format": "2.9.0", "Changes": [ { "Action": "EditImage", "Target": "Maps/springobjects", "FromFile": "assets/fish-object.png", "ToArea": { "X": 160, "Y": 80, "Width": 16, "Height": 16 } } ] } ``` -------------------------------- ### Use Token as Image File Path Placeholder Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/tokens.md Demonstrates how to use the 'season' token to dynamically select an image file based on the current in-game season. This allows for seasonal variations in game assets. ```json { "Action": "EditImage", "Target": "Buildings/houses", "FromFile": "assets/{{season}}_house.png" // assets/spring_house.png, assets/summer_house.png, etc } ``` -------------------------------- ### EditMap Action in JSON Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide.md The 'EditMap' action alters in-game maps. It allows changing map properties, tiles, pasting local maps, adding tilesheets, or resizing maps. This example replaces a specific area of the 'Town' map with a custom map file. ```json { "Format": "2.9.0", "Changes": [ { "Action": "EditMap", "Target": "Maps/Town", "FromFile": "assets/town.tmx", "ToArea": { "X": 22, "Y": 61, "Width": 16, "Height": 13 } } ] } ``` -------------------------------- ### EditData Action in JSON Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide.md The 'EditData' action allows modification of data within game assets, such as item prices or properties. It supports simple lookups and complex data models, enabling additions, edits, or deletions of entries. This example doubles the price of 'MossSoup'. ```json { "Format": "2.9.0", "Changes": [ { "Action": "EditData", "Target": "Data/Objects", "Fields": { "MossSoup": { "Price": 80 } } } ] } ``` -------------------------------- ### Migrate Legacy Location Names Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/custom-locations.md Shows how to use the MigrateLegacyNames property to rename a location while preserving player data from a previous version. ```json { "Format": "2.9.0", "CustomLocations": [ { "Name": "{{ModId}}_AbigailCloset", "FromMapFile": "assets/abigail-closet.tmx", "MigrateLegacyNames": [ "Custom_AbbyRoom" ] } ] } ``` -------------------------------- ### Content Patcher Patch Using i18n Token Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/translations.md A Content Patcher patch example demonstrating how to inject translated text into game data using the i18n token. This patch edits the 'Data/Objects' file to set the 'DisplayName' using a translated key. ```json { "Format": "2.9.0", "Changes": [ { "Action": "EditData", "Target": "Data/Objects", "Entries": { "{{ModId}}_Pufferchick": { "DisplayName": "{{i18n: item.name}}", "Price": 1200, ... } } } ] } ``` -------------------------------- ### Get Central Station API Instance in C# Source: https://github.com/pathoschild/stardewmods/blob/develop/CentralStation/docs/author-guide.md Shows how to retrieve the Central Station mod's API instance within a C# mod for Stardew Valley. This is typically done within the GameLaunched event handler by using the SMAPI Helper's ModRegistry. ```csharp var centralStation = this.Helper.ModRegistry.GetApi("Pathoschild.CentralStation"); if (centralStation is null) return; // Central Station not installed ``` -------------------------------- ### Synchronize Outfits Per NPC with Pinned Keys (JavaScript) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/tokens.md This example synchronizes outfit selections for multiple NPCs by using a tokenized pinned key. The key dynamically changes based on the target NPC, ensuring outfits are consistent for each NPC individually but can differ between NPCs. ```javascript { "Action": "Load", "Target": "Characters/Abigail, Portraits/Abigail, Characters/Haley, Portraits/Haley", "FromFile": "assets/{{Target}}-{{Random:hood, jacket, raincoat |key={{TargetWithoutPath}}-outfit}}.png" } ``` -------------------------------- ### Dynamic Randomization based on Time Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/tokens.md Shows how to use the Time token as a key to force randomization updates based on in-game time rather than the default day-start interval. ```text {{Random: a, b, c |key={{Time}} }} {{Random: a, b, c |key=Abigail portraits {{Time}} }} ``` -------------------------------- ### Check for Installed Mod Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/tokens.md Checks if a specific mod is installed by matching its UniqueID. This token returns the installed mod IDs. ```json "When": { "HasMod: SomeMod.UniqueID": "true" } ``` -------------------------------- ### Edit Deeply Nested Field in Stardew Valley Mods Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/action-editdata.md This example shows how to edit a deeply nested numerical field, specifically the 'Amount' within the 'StackModifiers' of a 'Golden Coconut' item in `Data/Objects`. It utilizes `TargetField` to navigate through multiple levels of nested objects and lists (entry ID, field name, list ID, field name) to pinpoint the exact field to modify. This allows for precise changes to complex data structures. ```json { "Format": "2.9.0", "Changes": [ { "Action": "EditData", "Target": "Data/Objects", "TargetField": [ "791", "GeodeDrops", "Default", "StackModifiers", "PineappleSeeds" ], "Entries": { "Amount": 20 } } ] } ``` -------------------------------- ### Add Translations for Config Options (JSON) Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/config.md Defines translation keys for config option names, descriptions, allowed values, and section headers. Supports multiple languages by creating separate JSON files (e.g., default.json, fr.json). ```json { "config.Material.name": "Material", "config.Material.description": "The material style for the billboard background.", "config.Material.values.Wood": "wood", "config.Material.values.Metal": "metal" } ``` ```json { "config.Material.name": "Matériel", "config.Material.description": "Le style du matériel pour l'arrière-plan du panneau d'affichage.", "config.Material.values.Wood": "bois", "config.Material.values.Metal": "métal" } ``` -------------------------------- ### Implement IMachine for custom processing logic Source: https://github.com/pathoschild/stardewmods/blob/develop/Automate/docs/technical.md Defines a custom machine class by implementing the IMachine interface. This class handles the machine's state, input processing (e.g., iron to gold bars), and output management. ```c# using Microsoft.Xna.Framework; using Pathoschild.Stardew.Automate.Framework; using StardewValley; using SObject = StardewValley.Object; namespace YourModName { public class TransmuterMachine : IMachine { private readonly SObject Entity; public GameLocation Location { get; } public Rectangle TileArea { get; } string MachineTypeID { get; } = "YourModId/Transmuter"; public TransmuterMachine(SObject entity, GameLocation location, in Vector2 tile) { this.Entity = entity; this.Location = location; this.TileArea = new Rectangle((int)tile.X, (int)tile.Y, 1, 1); } public MachineState GetState() { if (this.Entity.heldObject.Value == null) return MachineState.Empty; return this.Entity.readyForHarvest.Value ? MachineState.Done : MachineState.Processing; } public ITrackedStack GetOutput() { return new TrackedItem(this.Entity.heldObject.Value, onEmpty: item => { this.Entity.heldObject.Value = null; this.Entity.readyForHarvest.Value = false; }); } public bool SetInput(IStorage input) { if (input.TryGetIngredient(SObject.ironBar, 1, out IConsumable ingredient)) { ingredient.Take(); this.Entity.heldObject.Value = ItemRegistry.Create(SObject.goldBarQID); this.Entity.MinutesUntilReady = 120; return true; } return false; } } } ``` -------------------------------- ### GET /ChildNames Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/tokens.md Retrieves the names and genders of the player's children. ```APIDOC ## GET /ChildNames ### Description Returns the names and genders of the player's children in order of birth. ### Method GET ### Endpoint /ChildNames ### Response #### Success Response (200) - **children** (array) - List of objects containing name and gender. ### Response Example { "children": [ { "name": "Child1", "gender": "Male" }, { "name": "Child2", "gender": "Female" } ] } ``` -------------------------------- ### Load Game Asset Replacement Source: https://github.com/pathoschild/stardewmods/blob/develop/ContentPatcher/docs/author-guide/action-load.md Demonstrates the basic structure of a Content Patcher 'Load' action to replace a specific game asset with a custom file. This requires a valid content.json file with a defined format version. ```json { "Format": "2.9.0", "Changes": [ { "Action": "Load", "Target": "Portraits/Abigail", "FromFile": "assets/abigail.png" } ] } ``` -------------------------------- ### Define Automation Factory Logic in C# Source: https://github.com/pathoschild/stardewmods/blob/develop/Automate/docs/technical.md Demonstrates the factory pattern used to map game buildings to specific machine instances. This logic is used by the mod to identify and wrap entities into automatable objects. ```csharp if (building is FishPond pond) return new FishPondMachine(pond, location); if (building is Mill mill) return new MillMachine(mill, location); ```