Changes

Jump to navigation Jump to search
→‎Custom fruit trees: Fruit tree docs have been moved to the appropriate page Modding:Fruit trees
Line 1,224: Line 1,224:     
===Custom fruit trees===
 
===Custom fruit trees===
{{/doc status|[[Modding:Fruit trees]]|done=false}}
+
{{/doc status|[[Modding:Fruit trees]]|done=true}}
   −
====Data format====
+
You can now add custom [[Fruit Trees|fruit trees]] by editing the revamped <samp>Data/FruitTrees</samp> asset.
You can now add custom [[Fruit Trees|fruit trees]] by editing the revamped <samp>Data/fruitTrees</samp> asset. This consists of a string → model lookup, where...
  −
* The key is the [[#Custom items|unqualified item ID]] for the sapling item in <samp>Data/Objects</samp>.
  −
* The value is a model with the fields listed below.
     −
{| class="wikitable"
  −
|-
  −
! field
  −
! effect
  −
|-
  −
| <samp>DisplayName</samp>
  −
| A [[Modding:Tokenizable strings|tokenizable string]] for the tree's display name. This should return a display name without 'tree' (like <samp>Cherry</samp> for a cherry tree). This is used in UI messages like "''Your &lt;display name&gt; tree wasn't able to grow last night''".
  −
|-
  −
| <samp>Seasons</samp>
  −
| The seasons in which the fruit tree bears fruit. This consists of an array of season names (any combination of <samp>spring</samp>, <samp>summer</samp>, <samp>fall</samp>, or <samp>winter</samp>).
  −
  −
'''Note:''' the previous '<samp>island</samp>' season value is no longer valid. Using <samp>summer</samp> is equivalent to how it worked before (since we now have [[#Custom location contexts|per-location seasons]]).
  −
|-
  −
| <samp>Fruit</samp>
  −
| The fruit items to add to the tree each day while the tree is in-season. The first matching fruit (if any) is selected each day.
  −
  −
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 for fruit items.
  −
  −
Notes:
  −
* If set to an [[Modding:Item queries|item query]] which returns multiple items, one of them will be selected at random.
  −
* Season conditions are ignored in non-seasonal locations like the [[greenhouse]] and [[Ginger Island]].
  −
|-
  −
| <samp>Season</samp>
  −
| ''(Optional)'' If set, the group only applies if the tree's location is in this season. This is ignored in non-seasonal locations like the [[greenhouse]] and [[Ginger Island]].
  −
|-
  −
| <samp>Chance</samp>
  −
| ''(Optional)'' The probability that this entry is selected, as a value between 0 (never drops) and 1 (always drops). Default 1 (100% chance).
  −
|}
  −
|-
  −
| <samp>Texture</samp>
  −
| The asset name for the texture under the game's <samp>Content</samp> folder. Use <samp>\</samp> (or <samp>\\</samp> in JSON) to separate name segments if needed. For example, vanilla fruit trees use <samp>TileSheets\fruitTrees</samp>.
  −
|-
  −
| <samp>TextureSpriteRow</samp>
  −
| The tree's row index in the <samp>Texture</samp> spritesheet (e.g. 0 for the first tree, 1 for the second tree, etc).
  −
|-
  −
| <samp>PlantableLocationRules</samp>
  −
| ''(Optional)'' The rules to decide which locations you can plant the sapling in, if applicable. The first matching rule is used. This can override location checks (e.g. crops being limited to the farm), but not built-in requirements like crops needing dirt.
  −
  −
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 entry within the list.
  −
|-
  −
| <samp>Result</samp>
  −
| Indicates whether the sapling can be planted in a location if this entry is selected. The possible values are:
  −
* <samp>Default</samp>: the sapling can be planted if the location normally allows it. This can be used to stop processing further rules, and/or set a custom <samp>DeniedMessage</samp>.
  −
* <samp>Allow</samp>: the sapling can be planted here, regardless of whether the location normally allows it.
  −
* <samp>Deny</samp>: the sapling can't be planted here, regardless of whether the location normally allows it.
  −
|-
  −
| <samp>Condition</samp>
  −
| ''(Optional)'' A [[Modding:Game state queries|game state query]] which indicates whether this entry applies. Default true.
  −
|-
  −
| <samp>PlantedIn</samp>
  −
| ''(Optional)'' The planting context to apply this rule for. The possible values are <samp>Ground</samp> (planted directly in the ground), <samp>GardenPot</samp> (planted in a [[Garden Pot|garden pot]]), or <samp>Any</samp>. Default <samp>Any</samp>.
  −
  −
Note that saplings can't be planted in garden pots.
  −
|-
  −
| <samp>DeniedMessage</samp>
  −
| ''(Optional)'' If this rule prevents planting the sapling, the tokenizable string to show to the player (or <samp>null</samp> to default to the normal behavior for the context). This also applies when the <samp>Result</samp> is <samp>Default</samp>, if that causes the planting to be denied.
  −
|}
  −
|-
  −
| <samp>CustomFields</samp>
  −
| The [[#Custom data fields|custom fields]] for this entry.
  −
|}
  −
  −
For example, this content pack adds a custom fruit tree, including [[#Custom items|custom items]] for the sapling and fruit:
  −
  −
{{#tag:syntaxhighlight|<nowiki>
  −
{
  −
    "Format": "</nowiki>{{Content Patcher version}}<nowiki>",
  −
    "Changes": [
  −
        // add fruit + sapling items
  −
        // note: sapling must have an edibility under 0 (usually -300) to be plantable
  −
        {
  −
            "Action": "EditData",
  −
            "Target": "Data/Objects",
  −
            "Entries": {
  −
                "{{ModId}}_Pufferfruit": {
  −
                    "Name": "{{ModId}}_Pufferfruit", // best practice to match the ID, since it's sometimes used as an alternate ID
  −
                    "DisplayName": "Pufferfruit",
  −
                    "Description": "An example fruit item.",
  −
                    "Type": "Basic",
  −
                    "Category": -6,
  −
                    "Price": 1200,
  −
  −
                    "Texture": "Mods/{{ModId}}/Objects",
  −
                    "SpriteIndex": 0
  −
                },
  −
                "{{ModId}}_Puffersapling": {
  −
                    "Name": "{{ModId}}_Puffersapling",
  −
                    "DisplayName": "Puffersapling",
  −
                    "Description": "An example tree sapling.",
  −
                    "Type": "Basic",
  −
                    "Category": -74,
  −
                    "Price": 1200,
  −
  −
                    "Texture": "Mods/{{ModId}}/Objects",
  −
                    "SpriteIndex": 1
  −
                }
  −
            }
  −
        },
  −
  −
        // add fruit tree
  −
        {
  −
            "Action": "EditData",
  −
            "Target": "Data/FruitTrees",
  −
            "Entries": {
  −
                "{{ModId}}_Puffersapling": {
  −
                    "DisplayName": "Pufferfruit",
  −
                    "Seasons": [ "spring" ],
  −
                    "Fruit": [
  −
                        {
  −
                            "Id": "E{{ModId}}_Pufferfruit",
  −
                            "ItemId": "{{ModId}}_Pufferfruit"
  −
                        }
  −
                    ],
  −
                    "Texture": "Mods/{{ModId}}/FruitTrees",
  −
                    "TextureSpriteRow": 0
  −
                }
  −
            }
  −
        },
  −
  −
        // add images
  −
        {
  −
            "Action": "Load",
  −
            "Target": "Mods/{{ModId}}/FruitTrees, Mods/{{ModId}}/Objects",
  −
            "FromFile": "assets/{{TargetWithoutPath}}.png" // assets/FruitTrees.png, assets/Objects.png
  −
        },
  −
    ]
  −
}</nowiki>|lang=javascript}}
  −
  −
The fruit trees can then be added to the game by giving the player a sapling item in the usual ways (e.g. from [[#Custom shops|a shop]]).
  −
  −
====Fruit items====
   
For C# mods, the <samp>fruitsOnTree</samp> field (number of fruit on the tree) has been replaced by <samp>fruit</samp> (list of fruit items).
 
For C# mods, the <samp>fruitsOnTree</samp> field (number of fruit on the tree) has been replaced by <samp>fruit</samp> (list of fruit items).
   −
====Spawning fruit trees====
   
Custom trees can be added to the game in two ways:
 
Custom trees can be added to the game in two ways:
 
* Spawn them on [[Modding:Maps|map tiles]] when the location is created, using the new <samp>SpawnTree: fruit {{t|tree ID}} {{o|growth stage on location created}} {{o|growth stage on day-update regrowth}}</samp> tile property. This must be added on the <samp>Paths</samp> layer, which must also have tile index 34 from the <samp>paths</samp> tilesheet.
 
* Spawn them on [[Modding:Maps|map tiles]] when the location is created, using the new <samp>SpawnTree: fruit {{t|tree ID}} {{o|growth stage on location created}} {{o|growth stage on day-update regrowth}}</samp> tile property. This must be added on the <samp>Paths</samp> layer, which must also have tile index 34 from the <samp>paths</samp> tilesheet.
138

edits

Navigation menu