Modding:Farm data: Difference between revisions
imported>Tlitookilakin |
imported>Sunbeam135 mNo edit summary |
||
| (29 intermediate revisions by 5 users not shown) | |||
| Line 1: | Line 1: | ||
← [[Modding:Index|Index]] | |||
This page explains how the game stores and parses [[Farm Maps|farm types]], maps, and related data. This is an advanced guide for mod developers. | |||
'''Before reading this page''', see [[Modding:Editing XNB files]] for the basic concepts. | '''Before reading this page''', see [[Modding:Editing XNB files]] for the basic concepts. | ||
== | ==Assets== | ||
===Farm type data=== | |||
You can define custom farm types by editing the <samp>Data/AdditionalFarms</samp> asset. | |||
This consists of a list of models, where each model has the fields listed below. | |||
{| class="wikitable" | |||
|- | |||
! field | |||
! description | |||
|- | |||
| <samp>ID</samp> | |||
| A [[Modding:Common data field types#Unique string ID|unique string ID]] for the farm type. | |||
|- | |||
| <samp>TooltipStringPath</samp> | |||
| The [[Modding:Common data field types#Translation key|translation key]] containing the translatable farm name and description. For example, <samp>Strings/UI:Farm_Description</samp> will get it from the <samp>Farm_Description</samp> entry in the <samp>Strings/UI</samp> file. | |||
The translated text must be in the form "<samp>{{t|name}}_{{t|description}}</samp>", like "Pineapple Farm_A farm shaped like a pineapple". | |||
|- | |||
| <samp>MapName</samp> | |||
| The [[Modding:Common data field types#Asset name|asset name]] for the farm's [[Modding:Maps|map asset]], relative to the <samp>Maps</samp> folder. For example, <samp>Farm_Pineapple</samp> would load <samp>Maps/Farm_Pineapple</samp>. | |||
|- | |||
| <samp>IconTexture</samp> | |||
| ''(Optional)'' The [[Modding:Common data field types#Asset name|asset name]] for a 22x20 pixel icon texture, shown on the 'New Game' and co-op join screens. | |||
|- | |||
| <samp>SpawnMonstersByDefault</samp> | |||
| ''(Optional)'' The default value of the 'spawn monsters at night' [[Options#Advanced Game Options|advanced save option]]. | |||
|- | |||
| <samp>WorldMapTexture</samp> | |||
| ''(Optional)'' The [[Modding:Common data field types#Asset name|asset name]] for a 131x61 pixel texture that's drawn over the farm area in the in-game world map. | |||
|- | |||
| <samp>ModData</samp> | |||
| ''(Optional)'' The [[Modding:Common data field types#Mod data|mod data fields]] for this farm type, which can be accessed in C# code via <samp>Game1.GetFarmTypeModData(key)</samp>. | |||
|} | |||
===Farm map=== | |||
The farm [[Modding:Maps|map]] contains the general appearance and layout of your farm. [[Modding:Maps|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. | |||
===Farm map properties=== | |||
You can customize the farm behavior by [[Modding:Maps|setting map properties in the map asset]]. | |||
When testing map property changes, it's best to create a new save since some of these are only applied when the save is created. These properties are optional, and the game will use default values for any properties that aren't specified. | |||
Some notable map properties are: | |||
* [[Modding:Maps#Warps & map positions|Warp & map positions]] set the player position when arriving on the farm (e.g. <samp>BackwoodsEntry</samp> when arriving from the [[backwoods]], or <samp>WarpTotemEntry</samp> when using a [[Warp Totem: Farm|warp totem]] or [[Farm Obelisk|farm obelisk]]), and the default positions of some location contents (e.g. <samp>MailboxLocation</samp> for the default mailbox position). | |||
* [[Modding:Maps#Farmhouse interior|Farmhouse interior properties]] set the appearance and contents of the [[farmhouse]] (e.g. <samp>FarmHouseFlooring</samp> for the default flooring, or <samp>FarmHouseStarterGift</samp> for what's in the starter giftbox). | |||
* [[Modding:Maps#Fishing|Fishing properties]] override fishing and crab pot behavior. | |||
* [[Modding:Maps#Plants, forage, & item spawning|Plants, forage, & item spawning properties]] override how crops, forage, artifact spots, etc work on the farm. | |||
===Location data=== | |||
'''Optionally''', you can override additional farm location behavior by [[Modding:Location data|editing <samp>Data/Locations</samp>]]. Each farm type can have its own entry, with a key in the form <samp>Farm_{{t|farm type ID}}</samp>. If omitted, it defaults to the location data for the standard farm layout. | |||
This can be used to override forage, fish, crab pot catches, artifact spots, etc. | |||
= | For custom farms, some fields should have specific values to preserve expected behavior: | ||
A | {| class="wikitable" | ||
|- | |||
! field | |||
! description | |||
|- | |||
| <samp>DisplayName</samp> | |||
| A [[Modding:Common data field types#Tokenizable string|tokenizable string]] for the farm name. It should contain at least the <samp>FarmName</samp> token to be sure the farm name is shown. The standard value is <code>[LocalizedText Strings\\StringsFromCSFiles:MapPage.cs.11064 [EscapedText [FarmName]]]</code>. | |||
|- | |||
| <samp>CreateOnLoad</samp> | |||
| Must be <samp>null</samp> or omitted. Any other value will create duplicate locations. | |||
|- | |||
| <samp>CanPlantHere</samp> | |||
| Should be <samp>true</samp> or omitted. If <samp>false</samp>, crops can't be grown on your farm. | |||
|} | |||
== | ==Example== | ||
For example, this [[Modding:Content Patcher|Content Patcher]] pack adds a farm type with custom location data. | |||
<syntaxhighlight lang="json"> | |||
{ | |||
"Changes": [ | |||
// add farm type | |||
{ | |||
"Action": "EditData", | |||
"Target": "Data/AdditionalFarms", | |||
"Entries": { | |||
"{{ModId}}_PineappleFarm": { // for technical reasons, you need to specify the ID here *and* in the 'ID' field | |||
"ID": "{{ModId}}_PineappleFarm", | |||
"TooltipStringPath": "Strings/UI:{{ModId}}", | |||
"MapName": "{{ModId}}", | |||
"IconTexture": "Mods/{{ModId}}/Icon", | |||
"WorldMapTexture": "Mods/{{ModId}}/WorldMap" | |||
} | |||
} | |||
}, | |||
// add farm name + description | |||
{ | |||
"Action": "EditData", | |||
"Target": "Strings/UI", | |||
"Entries": { | |||
"{{ModId}}": "Pineapple Farm_A farm shaped like a pineapple!" // tip: use {{i18n}} to translate it | |||
} | |||
}, | |||
// load map | |||
{ | |||
"Action": "Load", | |||
"Target": "Maps/{{ModId}}", | |||
"FromFile": "assets/map.tmx" | |||
}, | |||
// load icon | |||
{ | |||
"Action": "Load", | |||
"Target": "Mods/{{ModId}}/Icon, Mods/{{ModId}}/WorldMap", | |||
"FromFile": "assets/{{TargetWithoutPath}}.png" | |||
}, | |||
// custom location data | |||
{ | |||
"Action": "EditData", | |||
"Target": "Data/Locations", | |||
"Entries": { | |||
"Farm_{{ModId}}_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": "MixedSeeds", | |||
"ItemId": "(O)770", | |||
"Chance": 0.1, | |||
"MaxStack": 3 | |||
}, | |||
{ | |||
"Id": "Stone", | |||
"ItemId": "(O)390", | |||
"Chance": 0.25, | |||
"MaxStack": 3 | |||
}, | |||
// custom artifacts | |||
{ | |||
"Id": "SpringSeeds", | |||
"ItemId": "(O)495", | |||
"Chance": 0.2, | |||
"MaxStack": 4, | |||
"Condition": "SEASON Spring", | |||
"Precedence": 1 | |||
}, | |||
{ | |||
"Id": "SummerSeeds", | |||
"ItemId": "(O)496", | |||
"Chance": 0.2, | |||
"MaxStack": 4, | |||
"Condition": "SEASON Summer", | |||
"Precedence": 1 | |||
}, | |||
{ | |||
"Id": "FallSeeds", | |||
"ItemId": "(O)497", | |||
"Chance": 0.2, | |||
"MaxStack": 4, | |||
"Condition": "SEASON Fall", | |||
"Precedence": 1 | |||
}, | |||
{ | |||
"Id": "WinterSeeds", | |||
"ItemId": "(O)498", | |||
"Chance": 0.2, | |||
"MaxStack": 4, | |||
"Condition": "SEASON Winter", | |||
"Precedence": 1 | |||
} | |||
] | |||
} | |||
} | |||
} | |||
] | |||
} | |||
</syntaxhighlight> | |||
[[Category:Modding]] | |||
[[ru:Модификации:Ферма]] | |||
[[ | [[zh:模组:农场数据]] | ||
Latest revision as of 18:07, 6 March 2026
← Index
This page explains how the game stores and parses farm types, maps, and related data. This is an advanced guide for mod developers.
Before reading this page, see Modding:Editing XNB files for the basic concepts.
Assets
Farm type data
You can define custom farm types by editing the Data/AdditionalFarms asset.
This consists of a list of models, where each model has the fields listed below.
| field | description |
|---|---|
| ID | A unique string ID for the farm type. |
| TooltipStringPath | The translation key containing the translatable farm name and description. 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 " |
| MapName | The asset name for the farm's map asset, 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. |
| SpawnMonstersByDefault | (Optional) The default value of the 'spawn monsters at night' advanced save option. |
| 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) The mod data fields for this farm type, which can be accessed in C# code via Game1.GetFarmTypeModData(key). |
Farm map
The farm map contains 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.
Farm map properties
You can customize the farm behavior by setting map properties in the map asset.
When testing map property changes, it's best to create a new save since some of these are only applied when the save is created. These properties are optional, and the game will use default values for any properties that aren't specified.
Some notable map properties are:
- Warp & map positions set the player position when arriving on the farm (e.g. BackwoodsEntry when arriving from the backwoods, or WarpTotemEntry when using a warp totem or farm obelisk), and the default positions of some location contents (e.g. MailboxLocation for the default mailbox position).
- Farmhouse interior properties set the appearance and contents of the farmhouse (e.g. FarmHouseFlooring for the default flooring, or FarmHouseStarterGift for what's in the starter giftbox).
- Fishing properties override fishing and crab pot behavior.
- Plants, forage, & item spawning properties override how crops, forage, artifact spots, etc work on the farm.
Location data
Optionally, you can override additional farm location behavior by editing Data/Locations. Each farm type can have its own entry, with a key in the form Farm_<farm type ID>. If omitted, it defaults to the location data for the standard farm layout.
This can be used to override forage, fish, crab pot catches, artifact spots, etc.
For custom farms, some fields should have specific values to preserve expected behavior:
| field | description |
|---|---|
| DisplayName | A tokenizable string for 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 omitted. Any other value will create duplicate locations. |
| CanPlantHere | Should be true or omitted. If false, crops can't be grown on your farm. |
Example
For example, this Content Patcher pack adds a farm type with custom location data.
{
"Changes": [
// add farm type
{
"Action": "EditData",
"Target": "Data/AdditionalFarms",
"Entries": {
"{{ModId}}_PineappleFarm": { // for technical reasons, you need to specify the ID here *and* in the 'ID' field
"ID": "{{ModId}}_PineappleFarm",
"TooltipStringPath": "Strings/UI:{{ModId}}",
"MapName": "{{ModId}}",
"IconTexture": "Mods/{{ModId}}/Icon",
"WorldMapTexture": "Mods/{{ModId}}/WorldMap"
}
}
},
// add farm name + description
{
"Action": "EditData",
"Target": "Strings/UI",
"Entries": {
"{{ModId}}": "Pineapple Farm_A farm shaped like a pineapple!" // tip: use {{i18n}} to translate it
}
},
// load map
{
"Action": "Load",
"Target": "Maps/{{ModId}}",
"FromFile": "assets/map.tmx"
},
// load icon
{
"Action": "Load",
"Target": "Mods/{{ModId}}/Icon, Mods/{{ModId}}/WorldMap",
"FromFile": "assets/{{TargetWithoutPath}}.png"
},
// custom location data
{
"Action": "EditData",
"Target": "Data/Locations",
"Entries": {
"Farm_{{ModId}}_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": "MixedSeeds",
"ItemId": "(O)770",
"Chance": 0.1,
"MaxStack": 3
},
{
"Id": "Stone",
"ItemId": "(O)390",
"Chance": 0.25,
"MaxStack": 3
},
// custom artifacts
{
"Id": "SpringSeeds",
"ItemId": "(O)495",
"Chance": 0.2,
"MaxStack": 4,
"Condition": "SEASON Spring",
"Precedence": 1
},
{
"Id": "SummerSeeds",
"ItemId": "(O)496",
"Chance": 0.2,
"MaxStack": 4,
"Condition": "SEASON Summer",
"Precedence": 1
},
{
"Id": "FallSeeds",
"ItemId": "(O)497",
"Chance": 0.2,
"MaxStack": 4,
"Condition": "SEASON Fall",
"Precedence": 1
},
{
"Id": "WinterSeeds",
"ItemId": "(O)498",
"Chance": 0.2,
"MaxStack": 4,
"Condition": "SEASON Winter",
"Precedence": 1
}
]
}
}
}
]
}