Open main menu
Home
Random
Log in
Settings
About Stardew Valley Wiki
Disclaimers
Stardew Valley Wiki
Search
Changes
← Older edit
Newer edit →
Modding:Modder Guide/APIs/Content Packs
(view source)
Revision as of 16:05, 17 December 2018
558 bytes removed
,
16:05, 17 December 2018
update for SMAPI 2.9.3
Line 12:
Line 12:
You can get a list of content packs installed for your mod, and access the files within it:
You can get a list of content packs installed for your mod, and access the files within it:
<source lang="c#">
<source lang="c#">
−
foreach(IContentPack contentPack in this.Helper.
GetContentPacks
())
+
foreach(IContentPack contentPack in this.Helper.
ContentPacks.GetOwned
())
{
{
this.Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}");
this.Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}");
Line 29:
Line 29:
</source>
</source>
−
{{SMAPI upcoming|2.10|
+
In specialised cases, you can create a
temporary
content pack for a given directory path:
−
You can get a list of content packs installed for your mod, and access the files within it:
−
<source lang="c#">
−
foreach(IContentPack contentPack in this.Helper.ContentPacks.GetOwned())
−
{
−
this.Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}");
−
−
// read a JSON file
−
YourDataFile data = contentPack.ReadJsonFile<YourDataFile>("content.json");
−
−
// load an asset or image
−
Texture2D image = contentPack.LoadAsset<Texture2D>("image.png");
−
}
−
</source>
−
−
In specialised cases, you can create a
fake
content pack for a given directory path:
<source lang="c#">
<source lang="c#">
// create with random manifest data
// create with random manifest data
Line 61:
Line 46:
);
);
</source>
</source>
−
}}
{{modding guide footer
{{modding guide footer
Pathoschild
translators
8,441
edits