Modding:Minecarts

From Stardew Valley Wiki
Jump to navigation Jump to search

Index

This page explains minecarts. This is an advanced guide for mod developers.

Format

You can now extend minecarts by editing the Data\Minecarts data asset.

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

  • The key is a unique string ID for the minecart network. When you interact with a minecart, the destinations listed for its network are shown.
  • The value is a model with the fields listed below.
field effect
Destinations The destinations which the player can travel to from minecarts in this network. This consists of a list of model with these fields:
field effect
Id A unique string ID for this destination within the network.
DisplayName A tokenizable string for the destination name shown in the minecart menu. You can use the location's display name with the LocationName token (like [LocationName Desert] for the desert).
TargetLocation The location ID for the destination.
TargetTile The destination tile position within the location, specified as a model with X and Y fields.
TargetDirection The direction the player should face after arrival (one of down, left, right, or up).
Condition (Optional) A game state query which indicates whether this minecart destination is available. Defaults to always available.
Price (Optional) The gold price that must be paid each time to use this destination. Default none.
BuyTicketMessage (Optional) If the destination costs money to use, a tokenizable string for the purchase confirmation message shown. If present, {0} is replaced with the purchase price. Defaults to the network's BuyTicketMessage field.
CustomFields (Optional) The custom fields for this entry.
UnlockCondition (Optional) A game state query which indicates whether this minecart network is unlocked. Default always enabled.
LockedMessage (Optional) A tokenizable string for the message shown when interacting with a minecart when the UnlockCondition false. Defaults to an "Out of order" translation.
ChooseDestinationMessage (Optional) A tokenizable string for the message shown when listing destinations to choose from. Defaults to a "Choose destination:" translation.
BuyTicketMessage (Optional) When a destination costs money to use, a tokenizable string for the purchase confirmation message shown. If present, {0} is replaced with the purchase price. Defaults to a "Buy a ticket for {0}g?" translation.

Open a minecart menu

You can use an Action: MinecartTransport [network ID] [exclude destination ID] map property to open the minecart menu. When the player interacts with the tile, it'll open the menu for the [network ID] network (default Default). if [exclude destination ID] is specified, the matching destination will be hidden from the list (usually because you're at that minecart). For example, the bus stop minecart uses Action: MinecartTransport Default Bus.

From a C# mod, you can call Game1.currentLocation.ShowMineCartMenu(networkId, excludeDestinationId) which works the same way (except that networkId is required).

Example

This Content Patcher content pack adds the Railroad as a minecart destination, complete with a map edit adding a decorative minecart. It is available after the Earthquake has occurred and minecarts have been unlocked.

{
    "Format": "2.5.0",
    "Changes": [
        // add minecart destination
        {
            "Action": "EditData",
            "Target": "Data/Minecarts",
            "TargetField": [ "Default", "Destinations" ], // for the "Default" network, edit the "Destinations" field
            "Entries": {
                "Railroad": {
                    "Id": "Railroad",
                    "DisplayName": "[LocationName Railroad]",
                    "Condition": "LOCATION_ACCESSIBLE Railroad",

                    "TargetLocation": "Railroad",
                    "TargetTile": { "X": 16, "Y": 39 },
                    "TargetDirection": "down",
                }
            }
        },

        // add decorative minecart
        {
            "Action": "EditMap",
            "Target": "Maps/Railroad",
            "FromFile": "assets/Custom_Railroad_Minecart.tmx",
            "ToArea": { "X": 15, "Y": 35, "Width": 4, "Height": 5 }
        }
    ]
}