Changes

Line 54: Line 54:     
==Mod APIs==
 
==Mod APIs==
===Content packs===
  −
A content pack is a sub-mod containing files your mod can read. These are installed just like a regular SMAPI mod, but don't do anything on their own. These must specify your mod in their <tt>manifest.json</tt>. See [[Modding:Content packs]] for more info about content packs.
  −
  −
SMAPI provides a method to get content packs loaded for your mod, and each content pack has an API you can use to read its files:
  −
<source lang="c#">
  −
foreach(IContentPack contentPack in this.Helper.GetContentPacks())
  −
{
  −
    // read content pack manifest
  −
    this.Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version}");
  −
  −
    // read a JSON file
  −
    YourDataFile data = contentPack.ReadJsonFile<YourDataFile>("content.json");
  −
  −
    // load an asset or image
  −
    Texture2D image = contentPack.LoadAsset<Texture2D>("image.png");
  −
}
  −
</source>
  −
   
===Logging===
 
===Logging===
 
Your mod can write messages to the console window and log file using the monitor. For example, this code:
 
Your mod can write messages to the console window and log file using the monitor. For example, this code:
translators
8,404

edits