Changes

add example
Line 71: Line 71:  
|-
 
|-
 
|}
 
|}
 +
 +
==Example==
 +
This is an example of a [[Modding:Content Patcher|Content Patcher]] pack adding a custom farm type with custom location data.
 +
{{#tag:syntaxhighlight|
 +
{
 +
    "Format": "{{Content Patcher version}}",
 +
    "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 <nowiki>{{i18n}}</nowiki> 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/<nowiki>{{TargetWithoutPath}}</nowiki>.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},
 +
                    "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
 +
                        }
 +
                    ]
 +
                }
 +
            }
 +
        }
 +
    ]
 +
}|lang=javascript}}
    
[[Category:Modding]]
 
[[Category:Modding]]