Tutorial: Adding Sitting to Custom Map Chairs

From Stardew Modding Wiki
Jump to navigation Jump to search

[This tutorial is a WIP by Majickian and should not be considered a finished product at this time.]

This is a tutorial for adding the ability to sit on custom chair tiles place on a custom map.

Introduction

So, you’ve created your fancy custom map only to realize the impeccably re-created 1809 chaise lounge you pictured as antique Ferngill Republic furniture – the one which you spent hours meticulously pixeling - is just a lump of pretty set dressing. How can you give that form a little function?

The 1.5 release of Stardew Valley allowed players to sit on chairs. This wasn't just the furniture chairs placed by the player, but also chairs found across the valley. The player can now sit on Sebastian's couch waiting for him to be off work, or hop on a stool at the Saloon and order a drink with the rest of the village.

Through the use of Content Patcher, modders are able to extend this same functionality to their own custom seating or vanilla chairs placed on custom tilesheets.

What You Need

  • A Custom Tilesheet
  • Content Patcher by Pathoschild
  • Your mod’s content.json file

Note to Readers

This tutorial will presume you already know something about map making and using Content Patcher. If you find yourself needing a refresher on any of these topics, see the suggested links at the end of the article.

Basic Theory Explained

The base game contains a file Data\ChairTiles.json which tells the game which tiles on the specified tilesheet(s) are considered chairs for the purpose of sitting mechanics. When properly set, a player selecting the seat will sit facing the correct direction. This feature is purely cosmetic unless additional features are added through further modding.

Breaking it Down

In order for any of this to function all tiles referenced in code need to be placed on the Buildings map layer.

The code format used requires a key (where), followed by a value set (what).

Key: Tilesheet Name/X position/Y position:
Value: tile width/tiles height/direction/type/draw tile X/draw tile Y/seasonal/alternate draw tilesheet

In practice this looks like:
"townInterior/9/16": "1/1/down/chair/-1/-1/false"

Don’t worry if this is still confusing – we’ll break it down further as we go.

A Quick Note on Draw Tiles

Some seating requires an extra layer drawn over the player sprite to create the 3D perspective of the player sitting IN the chair, rather than ON the chair. The X, Y position of these draw tiles are taken from TileSheets\ChairTiles, unless otherwise specified in the Alternate Draw Tilesheet value. Their size is relative to the setting in tile width and tile height, starting from the upper left tile.

Keys Explained

Tilesheet name

This is the name of your tilesheet file, minus the file type extension. If this is a custom tilesheet, the tilesheet will need to be loaded in your content.json file. More on this is discussed in the guide below.

X Position

This is the horizontal location of the tile starting from the upper left corner and moving right. Counting always begins with 0. If Tile Width is set higher than 1, this needs to be set to the left-most tile. See suggested links for more in-depth explanations of this concept.

Y Position

This is the vertical location of the tile starting from the upper left corner and moving right. Counting always begins with 0. If Tile Hight value is set higher than 1, this needs to be set to the top-most tile. See suggested links for more in-depth explanations of this concept.

Values Explained

Once you’ve established which tilesheet and which tile location(s), what you’ll spend the most time on are the value options. Which means this is the first place to check when something goes wrong. See the chair types for exceptions to these rules.

Tile Width

How wide the number of seating tiles should be. This value will always be set to 1 or higher. It is used to extend the seating code to the right by the number indicated. Extensions in the base game code are used for seats like booths and picnic benches.

Tile Height

How tall the number of seating tiles should be. This value will always be set to 1 or higher. It is used to extend the seating code down by the number indicated. Extensions in the base game code are used for seats like couches and benches.

Direction

Player direction while sitting. The available options for direction are Up Down Left Right and Opposite. Anything else used in this field will default to facing up. Opposite seats the player in the direction reverse to what they were when facing the seat. An example of this being used is with the backless benches found inside the Spa locker rooms.

Type

Sets chair logic. Several pre-existing chair types are available, providing differences to seating placement within a tile, direction, and draw layering. Using an alternate value will bypass and ignore these logic points. For individual seat options, see chair types.

Draw Tile X-axis

Numerical value. The X position on TileSheets\ChairTiles (unless otherwise indicated) where the draw tile is located. When Tile Width is larger than 1, this position should be set to the left-most tile used for draw tiles.

Draw Tile Y-axis

Numerical Value. The Y position on TileSheets\ChairTiles (unless otherwise indicated) where the draw tile is located. When Tile Height is larger than 1, this position should be set to the upper-most tile used for draw tiles.

Seasonal

True or False value. This says whether to use different draw tiles for different seasons. It works in conjunction with Tile Width/Height and Draw Tile Width/Height to determine where on TileSheets\ChairTiles to take the draw tiles from. Seasonal sets should be grouped together from left to right in the order of spring/summer/fall/winter.

Alternate Draw Tilesheet

Tells all other draw tile logic to read this sheet instead of TileSheets\ChairTiles. Correct usage is TileSheets\\ followed by your file name without the file type extension. (e.g. TileSheets\\CustomChairFronts)

Chair Type Examples

There are 14 chair types used in Data\ChairTiles.json to look at for examples. Most settings raise or lower the character sprite to better match the height of the seat, and dependent on the direction faced while sitting. Several settings may also have unintended side effects if different directions are used than they were originally intended.

Chair Description Image
bench Different offsets by direction. Up=0 Right=.5 Down=.25 Left=.5 <Image>
booth <Verify logic. May only act as file description.> <Image>
chair <Verify logic. May only act as file description.> <Image>
couch <Verify logic. May only act as file description.> <Image>
highback_chair This is used for any highback chair that faces up. Raises character height by 1 <Image>
picnic Directional offsets. Up lowers offset by .25, Down raises offset by .25. No additional offsets for Right/Left as there are no picnic tables in this style. <Image>
playground Only used with the bird shaped seat in the playground. Offsets X-axis by .75 <Image>
stool Player sits in the direction they were facing, regardless of coded direction. <Image>
stool short Uses stool seating logic, but lowers the player on the Y-axis by .3 <Image>
stool tall Only used for the stool at Haley’s makeup table. Follows stool seating logic and raises the character placement on the Y axis by .3 <Image>
summitbench Raises character offset by .2 regardless of direction. Intended for up facing direction. Present in hardcode but not used in Data\ChairTiles <Image>
swings Only used at the playground. Raises character offset by .5 regardless of direction. Directions other than Down are untested. <Image>
bathchair tall Only used for the seating in the Spa. Character will always face down if they would normally have faced up. Raises character placement on the Y axis by .3 <Image>
chair tall This is used for the chair in Elliott’s shack, and selected seats in the Spa. Offsets the player on the Y axis by .5 but otherwise uses regular chair logic. <Image>
ccdesk This is only used for the chair at the Community Center desk. It is the only option for

offsetting the player sprite on the X-axis by .5 but also raises Y-axis placement by 1. Unusable for regular armchairs.|| <Image>

Diving A Little Deeper

Now that you’ve looked over all of this and surely memorized it in one go, let’s take a closer look at another example from the game code. This example is from the left hand side of the downward-facing bench in Pelican Town.

"spring_town/2/10": "1/1/down/bench/-1/-1/false",
Entry Key
spring_town: This indicates the tilesheet used is spring_town.png
2: Starting from 0 and moving right, the tile’s position is 2
10: Starting from 0 and moving down, the tile’s position is 10

Entry Values
1: Does not extend right
1: Does not extend down
down: The player will use downward facing sprites while sitting
bench: The sprite position within the tile will use logic for bench seating
-1: No draw tile(s) will be used
-1: No draw tile(s) will be used
false: No seasonal variants will occur

Guide to Adding New Chairs

Coming Soon!

Limitations

At the time of writing, there is no code to allow mod authors to sit in armchairs using this method, as it needs to offset the player on the X-axis by .5 and this is not a pre-set value, as no chairs from Stardew Valley interior maps use regular armchairs. Mod authors may work around this by using the ccdesk chair type and off-setting their custom chair to coordinate with the height the player sits. ccdesk will not align with the five original armchairs from TileSheets\furniture.

Suggested Links

Content Patcher Author’s Guide
Modding Maps on Stardew Valley Wiki
Lemurkat’s Tutorial on Making a New Area
XxHarvzBackxX Video Series on Map Making

Additional To-Do List

  • Grammar and Formatting
  • Peer Review
  • Photos. So many photos.
  • Verify game code for chair logic
  • Check use of StartsWith and EndsWith for (working) alternate chair options
  • Maybe: A "what happens" gallery of seating (combinations + directions)