Modding Tips and Tricks by Elizabeth
How Tilesheet Paths Work
Here's how I'd phrase it, a bit metaphorically:
TMX file: hey my tilesheets are in "assets/tilesheetname" relative to me! (or in the same folder if it's a vanilla tilesheet)
Content Patcher: okay, cool, let me check there.
- If it sees them in that relative path: all good, loads up
- if it's not there: hmm, maybe this is a vanilla tilesheet. I will check in Content/Maps/relativetilesheetpath.
- If it's there: all good, proceed as normal, plus since you're pulling from Content any recolors are already applied to vanilla tilesheets.
- If it's not there: panic!
File Structure for Mapmaking
So, the way I usually do it is:
- Set up a folder in Documents for Stardew Modding
- Set up a subfolder there named Maps
- Copy the vanilla Maps folder contents into my Maps folder from my unpacked game content
- Do all my edits inside Stardew Modding/Maps
The way some people do it is:
- Set up a folder in your Mods folder named YourAwesomeMod
- Add an assets folder inside that, and put your .tmx files and all the vanilla tilesheets and any mod-added tilesheets (DaisyNiko, Lumi's, etc) into there.
OR
- Set up a folder in your Mods folder named YourAwesomeMod
- Put your modded .tmx directly into the YourAwesomeMod folder along with all the vanilla tilesheets and any mod-added tilesheets, plus have an YourAwesomeMod/assets/ folder for any new tilesheets you add
With either of the last two approaches, you can add a . in front of all the vanilla tilesheets and any tilsheets from other mods, and Content Patcher/SMAPI will use the tilesheets in Content/Maps (ignoring the ones in your mod folder). However, you have to remember to delete all the tilesheets before release, to avoid redistributing assets you don't have permissions for or unnecessarily redistributing game assets.
The danger with my preferred approach is that if you're not careful, you can accidentally get an absolute tilesheet path instead of a relative tilesheet path, triggering the "climbing tilesheets" error. Also of course I regularly run the risk of being like "ah yes I totally copied things over before loading up to test" when I definitely didn't. But I don't need to prefix my tilesheets with a . (which is more annoying on a Mac) and I don't have any risk of accidentally redistributing too many tilesheets.
The Virtual Content Folder, Or: How To Use The Content Pipeline For Everything
SMAPI is a mod loader, so at its heart, it takes mods and helps them interface with the game. One way it does this is through what Pathoschild calls the "content pipeline". The way I think of it is that SMAPI and Content Patcher build a "virtual" version of the Content
folder, and whenever the game asks for something in Content
, they intercept that request and hand back what's in the virtual folder instead.
If you want to have a good mental picture of what's in this "virtual" Content
folder, you can start by unpacking the base game's Content
folder, using StardewXNBHack or similar. This is the base that SMAPI and CP build on top of, so every mod edit to Content
gets applied on top of this. Mentally, I picture this like building a stack of pancakes: the base game is like the plate, and each edit plops down in some order on top, and the final thing you see is looking down from above on the pancake stack. (Okay, the fact these pancakes have "holes" where they leave the base game stuff alone makes the metaphor break down a bit...)
If you write content packs, you will mostly just use CP to edit this "virtual" Content
folder, by putting the name of something in the "virtual" Content
folder (or something you want to newly exist there) into the Target
part of a CP patch. Checking out all the troubleshooting tools CP provides helps a lot with understanding what's going on there. Notably, patch export ASSETNAME
will give you back the "virtual" version of a specific thing in the "virtual" Content
folder, to help you get an idea of what the result is after applying all the edits from all the mods. In addition, patch summary
will give a summary of which mods are editing what at a given time.
The Content Folder is Weird
There's a few quirks to the Content
folder, including:
- Everything that ever gets used in a map lives in the
Maps
folder. Notably, this includesMaps/springobjects
, which contains the sprites for every item in the game. - Walk sprites go in
Characters/NPCNAME
, while portraits go intoPortraits/NPCNAME
. Since these have the same ending filename, occasionally people swap them, with hilarious results. - Can't find something from the game? It's probably in
LooseSprites/Cursors
.
Using the Content Pipeline for Evil (C#)
If you're writing C# mods, you can sneakily take advantage of all these nice tools! You can get other mods (content packs) to load images or data to an unused corner of this "virtual" Content
folder, and then grab them back out after all the edits are done using Helper.GameContent.Load
. Generally C# mods that do this use a folder named something like Mods/yourname.yourmodname/yourassetname
. Some examples include: Tractor Mod for the tractor texture, Sound Tweaker for the information about which sounds to tweak, and HD Portraits for both the textures and the information about how much upscaled they are. Sometimes mods also add extra strings to files like Strings/StringsFromCSFiles
or Strings/StringsFromMaps
, using a key that's unique to their mod (includes the unique ID of the mod or something similar).