This wiki is a read-only version of the Stardew Valley Wiki. The official editable wiki maintained by ConcernedApe can be found at stardewvalleywiki.com

Changes

Jump to: navigation, search

Modding:Modder Guide/APIs/Utilities

221 bytes added, 15:46, 30 September 2020
Mod path: expand
==Metadata==
===Mod path===
Before handling mod folder paths, be aware that:* The '''mod's folder path is not consistent'''. The game is installed to different paths, Nexus mods are often unzipped into a folder like <tt>Mods/Your Mod Name 1.27.5-541-1-27-5-1598664794/YourModFolder</tt> by default, and players can organize their mod folders like <tt>Mods/For single-player/YourModFolder</tt>.* Paths are formatted differently on Linux/Mac/Android vs Windows. You don't need to worry about that when using SMAPI APIs use , which take relative paths, so you rarely need and automatically fix the absolute pathformat if needed:
<source lang="c#">
var data = helper.Data.ReadJsonFile<SomeDataModel>("assets/data.json");
</source>
When If you do really need an absolute a full path, note that the '''mod's install path is not consistent'''. The game is installed to different paths, Nexus mods are often unzipped into a folder like you should use <tt>Mods/Your Mod Name 1this.27Helper.5-541-1-27-5-1598664794/YourModFolderDirectoryPath</tt> by default, and players can organize their mod folders like <tt>Mods/For single-player/YourModFolderPath.Combine</tt>. You should use the <code>this.Helper.DirectoryPath</code> to get an absolute path if you need it:
<source lang="c#">
string filePath path = Path.Combine(this.Helper.DirectoryPath, "assets", "data.json");// "assets/data.json" in the current mod's foldervar file = new FileInfo(filePathpath);
</source>
See ''[[#Constants|Constants]]'' for other pathslike the game folder.
===Constants===
Protected, translators
5,421
edits

Navigation menu