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

844 bytes added, 15:28, 30 September 2020
Metadata: + mod path
==Metadata==
===Mod path===
SMAPI APIs use relative paths, so you rarely need the absolute path:
<source lang="c#">
var data = helper.Data.ReadJsonFile<SomeDataModel>("assets/data.json");
</source>
 
When you do need an absolute 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 <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>. You should use the <code>this.Helper.DirectoryPath</code> to get an absolute path if you need it:
<source lang="c#">
string filePath = Path.Combine(this.Helper.DirectoryPath, "assets", "data.json");
var file = new FileInfo(filePath);
</source>
 
See ''[[#Constants|Constants]]'' for other paths.
 
===Constants===
The <tt>Constants</tt> class provides metadata about SMAPI and the game.
Protected, translators
5,421
edits

Navigation menu