Difference between revisions of "Modding:Farm data"

From Stardew Valley Wiki
Jump to navigation Jump to search
m (→‎Example: formatting fixes. removed 'Format' field temporarily)
Line 14: Line 14:
  
 
===Entry Properties===
 
===Entry Properties===
These map properties can change where a player enters the farm when arriving from other locations, such as the backwoods, bus stop, or forest.
+
These map properties can change where a player enters the farm when arriving from other locations, such as the backwoods, bus stop, or forest. Each uses the format [{{t|int x}} {{t|int y}}].
 +
 
 +
{| class="wikitable"
 +
|-
 +
! property
 +
! entering from
 +
|-
 +
| <samp>BackwoodsEntry</samp>
 +
| [[Backwoods|The backwoods]]
 +
|-
 +
| <samp>BusStopEntry</samp>
 +
| [[Bus Stop|The bus stop]]
 +
|-
 +
| <samp>FarmCaveEntry</samp>
 +
| [[The Cave|The farm cave]]
 +
|-
 +
| <samp>ForestEntry</samp>
 +
| [[Cindersap Forest|The cindersap forest]]
 +
|-
 +
| <samp>WarpTotemEntry</samp>
 +
| Using a [[Warp Totem: Farm|warp totem]], or the [[Farm Obelisk|Ginger Island farm obelisk]]
 +
|}
  
 
===Building Properties===
 
===Building Properties===

Revision as of 23:11, 5 February 2024

Axe.png
Article Stub

This article is a stub and is missing information. You can help Stardew Valley Wiki by expanding it!

The following describes the upcoming Stardew Valley 1.6, and may change before release.

Index

This page explains how to create a custom farm type. It is an advanced guide for modders. Before reading this page, see Modding:Editing XNB files for the basic concepts.

Files to Edit

Creating a custom farm requires editing some files and adding new ones. However, you don't need any programming experience and it can be done with Content Patcher.

Farm Map

A map controls the general appearance and layout of your farm. Modding:Maps describes the basic process of creating a map. Copying and editing an existing farm map is recommended to avoid problems with missing information. The map must be added to the game files, and not replace an existing one.

Entry Properties

These map properties can change where a player enters the farm when arriving from other locations, such as the backwoods, bus stop, or forest. Each uses the format [<int x> <int y>].

property entering from
BackwoodsEntry The backwoods
BusStopEntry The bus stop
FarmCaveEntry The farm cave
ForestEntry The cindersap forest
WarpTotemEntry Using a warp totem, or the Ginger Island farm obelisk

Building Properties

These map properties can change where some objects are positioned by default, such as the greenhouse, farmhouse, or grandpa's shrine.

Farmhouse Interior

The starter interior layout of the farmhouse and cabins can be modified using these map properties on the farm.

Other Properties

These map properties can change other aspects of the farm, such as regenerating hardwood stumps or rock-spawning quarries.

Farm Type

To use a custom farm type, it must be added to the game by editing Data/AdditionalFarms. Each entry is an object with these fields:

field description
ID A unique ID value. This must be globally unique across all mods, so you should prefix your mod ID (e.g., Example.PineapplesAnywhere/PineappleFarm). You should avoid commas for compatibility with Content Patcher packs checking the {{FarmType}} token. This is not shown in-game. It should be the same as the key for this entry.
TooltipStringPath Where to get the translatable farm name and description. This must be a key in the form <asset name>:<key>; for example, Strings/UI:Farm_Description will get it from the Farm_Description entry in the Strings/UI file. The translated text must be in the form "<name>_<description>", like "Pineapple Farm_A farm shaped like a pineapple".
MapName The map asset name relative to the Maps folder. For example, Farm_Pineapple would load Maps/Farm_Pineapple.
IconTexture (optional) The asset name for a 22x20 pixel icon texture, shown on the 'New Game' and co-op join screens.
WorldMapTexture (optional) The asset name for a 131x61 pixel texture that's drawn over the farm area in the in-game world map.
ModData (optional) A string→string dictionary of mod-specific metadata for the farm, which can be accessed in C# code via Game1.GetFarmTypeModData(key).

Location Data

This step is optional. Data/Locations contains additional information about the game's locations. Each farm type has its own entry. A custom farm type can use an entry identified by Farm_<Unique_ID> to change the location data of the farm when it is used. If this location data does not exist, the location data of the standard farm layout will be used instead.

For custom farms, some fields should have specific values to preserve expected behavior.

field description
DisplayName This is used to display the farm name. It should contain at least the FarmName token to be sure the farm name is shown. The standard value is

[LocalizedText Strings\\StringsFromCSFiles:MapPage.cs.11064 [EscapedText [FarmName]]]

CreateOnLoad Must be null or absent. Any other value will create duplicate locations.
CanPlantHere Should be true. If false or absent, crops can't be grown on your farm.

Example

This is an example of a Content Patcher pack adding a custom farm type with custom location data.

Data 
{
    "Changes": [
        // add farm type
        {
            "Action": "EditData",
            "Target": "Data/AdditionalFarms",
            "Entries": {
                "ExampleAuthor.PineappleFarm/PineappleFarm": { // for technical reasons, you need to specify the ID here *and* in the 'ID' field
                    "ID": "ExampleAuthor.PineappleFarm/PineappleFarm",
                    "TooltipStringPath": "Strings/UI:ExampleAuthor_PineappleFarm",
                    "MapName": "ExampleAuthor_PineappleFarm",
                    "IconTexture": "Mods/ExampleAuthor.PineappleFarm/Icon",
                    "WorldMapTexture": "Mods/ExampleAuthor.PineappleFarm/WorldMap"
                }
            }
        },

        // add farm name + description
        {
            "Action": "EditData",
            "Target": "Strings/UI",
            "Entries": {
                "ExampleAuthor_PineappleFarm": "Pineapple Farm_A farm shaped like a pineapple!" // tip: use {{i18n}} to translate it
            }
        },

        // load map
        {
            "Action": "Load",
            "Target": "Maps/ExampleAuthor_PineappleFarm",
            "FromFile": "assets/map.tmx"
        },

        // load icon
        {
            "Action": "Load",
            "Target": "Mods/ExampleAuthor.PineappleFarm/Icon, Mods/ExampleAuthor.PineappleFarm/WorldMap",
            "FromFile": "assets/{{TargetWithoutPath}}.png"
        },

        // custom location data
        {
            "Action": "EditData",
            "Target": "Data/Locations",
            "Entries": {
                "ExampleAuthor.PineappleFarm/PineappleFarm": {
                    "DisplayName": "[LocalizedText Strings\\StringsFromCSFiles:MapPage.cs.11064 [EscapedText [FarmName]]]",
                    "CanPlantHere": true,
                    "DefaultArrivalTile": {"X": 64, "Y": 15},
                    "MinDailyWeeds": 5,
                    "MaxDailyWeeds": 11,
                    "ArtifactSpots": [
                        // default artifact data
                        {
                            "Id": "Coal",
                            "ItemId": "(O)382",
                            "Chance": 0.5,
                            "MaxStack": 3
                        },
                        {
                            "Id": "Mixed_Seeds",
                            "ItemId": "(O)770",
                            "Chance": 0.1,
                            "MaxStack": 3
                        },
                        {
                            "Id": "Stone",
                            "ItemId": "(O)390",
                            "Chance": 0.25,
                            "MaxStack": 3
                        },
                        // custom artifacts
                        {
                            "Id": "Spring seeds",
                            "ItemId": "(O)495",
                            "Chance": 0.2,
                            "MaxStack": 4,
                            "Condition": "SEASON Spring",
                            "Precedence": 1
                        },
                        {
                            "Id": "Summer seeds",
                            "ItemId": "(O)496",
                            "Chance": 0.2,
                            "MaxStack": 4,
                            "Condition": "SEASON Summer",
                            "Precedence": 1
                        },
                        {
                            "Id": "Fall seeds",
                            "ItemId": "(O)497",
                            "Chance": 0.2,
                            "MaxStack": 4,
                            "Condition": "SEASON Fall",
                            "Precedence": 1
                        },
                        {
                            "Id": "Winter seeds",
                            "ItemId": "(O)498",
                            "Chance": 0.2,
                            "MaxStack": 4,
                            "Condition": "SEASON Winter",
                            "Precedence": 1
                        }
                    ]
                }
            }
        }
    ]
}