Jump to content

Modding:Powers: Difference between revisions

From Stardew Valley Wiki
imported>Tlitookilakin
Create page
 
imported>Sunbeam135
m added ru link
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{stub}}
← [[Modding:Index|Index]]
← [[Modding:Index|Index]]


This page explains how to add and edit [[Special Items & Powers|powers]], also known as "special items". It is an advanced guide for modders.
This page explains how the game stores and parses data for [[Special Items & Powers]]. This is an advanced guide for mod developers.
'''Before reading this page''', see [[Modding:Editing XNB files]] for the basic concepts.


==Overview==
==Overview==
Powers are unique "items" that can be obtained only once per player, and permanently unlock new abilities. Information for powers is stored in <samp>Data/Powers</samp>. This does '''not''', by itself, add any abilities to the player. It contains information used to display powers in the menu, and unlock them when needed.  
Powers are unique "items" that can be obtained only once per player, and permanently unlock new abilities. Information for powers is stored in <samp>Data/Powers</samp>. This does '''not''', by itself, add any abilities to the player. It contains information used to display powers in the menu, and unlock them when needed.  


==Format==
==Data format==
 
You can add/edit [[Special Items & Powers]] by editing the <samp>Data/Powers</samp> data asset.
 
This consists of a string → model lookup, where...
* The key is a [[Modding:Common data field types#Unique string ID|unique string ID]] for the entry.
* The value is a model with the fields listed below.
 
{| class="wikitable"
{| class="wikitable"
! Field
! Field
Line 21: Line 25:
|-
|-
| <samp>TexturePath</samp>
| <samp>TexturePath</samp>
| The path to the texture to use for the item sprite.
| The asset name for the power's icon texture.
|-
|-
| <samp>TexturePosition</samp>
| <samp>TexturePosition</samp>
| The pixel coordinates of the upper left corner of the sprite in the texture. Sprites are always <samp>16 x 16</samp>
| The pixel coordinates of the upper left corner of the sprite in the texture, provided as an object with <samp>X</samp> and <samp>Y</samp> fields. Sprites are always 16 by 16.
|-
|-
| <samp>UnlockedCondition</samp>
| <samp>UnlockedCondition</samp>
| A [[Modding:Game state queries|game state query]] used to determine whether or not the item has been unlocked.
| A [[Modding:Game state queries|game state query]] used to determine whether or not the item has been unlocked.
|-
| <samp>CustomFields</samp> ''(Optional)''
| The [[Modding:Common data field types#Custom fields|custom fields]] for this entry.
|}
|}


==Raw Data==
For example, this Content Patcher pack adds a custom pufferfish power, which is unlocked after the player catches a pufferfish:
TODO
 
{{Content Patcher example|<nowiki>
    "Changes": [
        // load the icon for the powers tab
        {
            "Action": "Load",
            "Target": "Mods/{{ModId}}/PufferIcon",
            "FromFile": "assets/PufferIcon.png"
        },
 
        // add the power
        {
            "Action": "EditData",
            "Target": "Data/Powers",
            "Entries": {
                "{{ModId}}_Pufferpower": {
                    "DisplayName": "Puffer's Blessing",
                    "Description": "You feel as if you have become one with the pufferfish...",
                    "TexturePath": "Mods/{{ModId}}/PufferIcon",
                    "TexturePosition": {
                        "X": 0,  // top-left corner of the canvas, assuming that this is the only sprite in the icon image
                        "Y": 0
                    },
                    "UnlockedCondition": "PLAYER_HAS_CAUGHT_FISH Current 128",  // the player has caught a pufferfish
                }
            }
        }
    ]
</nowiki>}}
 
[[Category:Modding]]
 
[[ru:Модификации:Способности]]
[[zh:模组:能力]]

Latest revision as of 18:48, 13 March 2026

← Index

This page explains how the game stores and parses data for Special Items & Powers. This is an advanced guide for mod developers.

Overview

Powers are unique "items" that can be obtained only once per player, and permanently unlock new abilities. Information for powers is stored in Data/Powers. This does not, by itself, add any abilities to the player. It contains information used to display powers in the menu, and unlock them when needed.

Data format

You can add/edit Special Items & Powers by editing the Data/Powers data asset.

This consists of a string → model lookup, where...

  • The key is a unique string ID for the entry.
  • The value is a model with the fields listed below.
Field Description
DisplayName A tokenizable string used to display the translated name of the item, once unlocked.
Description (Optional) A tokenizable string used to display the translated description of the item, once unlocked.
TexturePath The asset name for the power's icon texture.
TexturePosition The pixel coordinates of the upper left corner of the sprite in the texture, provided as an object with X and Y fields. Sprites are always 16 by 16.
UnlockedCondition A game state query used to determine whether or not the item has been unlocked.
CustomFields (Optional) The custom fields for this entry.

For example, this Content Patcher pack adds a custom pufferfish power, which is unlocked after the player catches a pufferfish:

{
    "Format": "2.8.0",
    "Changes": [
        // load the icon for the powers tab
        {
            "Action": "Load",
            "Target": "Mods/{{ModId}}/PufferIcon",
            "FromFile": "assets/PufferIcon.png"
        },

        // add the power
        {
            "Action": "EditData",
            "Target": "Data/Powers",
            "Entries": {
                "{{ModId}}_Pufferpower": {
                    "DisplayName": "Puffer's Blessing",
                    "Description": "You feel as if you have become one with the pufferfish...",
                    "TexturePath": "Mods/{{ModId}}/PufferIcon",
                    "TexturePosition": {
                        "X": 0,  // top-left corner of the canvas, assuming that this is the only sprite in the icon image
                        "Y": 0
                    },
                    "UnlockedCondition": "PLAYER_HAS_CAUGHT_FISH Current 128",  // the player has caught a pufferfish
                }
            }
        }
    ]
}