Difference between revisions of "Modding:Modder Guide/APIs/Manifest"

From Stardew Valley Wiki
Jump to navigation Jump to search
(→‎Basic examples: update suggested min versions)
(→‎Minimum SMAPI version: + MinimumGameVersion in SMAPI 4.0.6)
 
(22 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{../../header}}
 
{{../../header}}
  
Every SMAPI mod or content pack must have a <tt>manifest.json</tt> file in its folder. SMAPI uses this to identify and load the mod, perform update checks, etc. The manifest info is also available to any mod in code (using <tt>this.ModManifest</tt> for the current mod's manifest, or [[../#Mod registry|mod registry]] for other mods' manifests).
+
Every SMAPI mod or content pack must have a <samp>manifest.json</samp> file in its folder. SMAPI uses this to identify and load the mod, perform update checks, etc. The manifest info is also available to any mod in code (using <samp>this.ModManifest</samp> for the current mod's manifest, or [[../#Mod registry|mod registry]] for other mods' manifests).
  
 
==Basic examples==
 
==Basic examples==
Line 10: Line 10:
 
! For a content pack
 
! For a content pack
 
|-
 
|-
| <source lang="javascript">
+
| <syntaxhighlight lang="javascript">
 
{
 
{
  "Name": "YourProjectName",
+
    "Name": "Your Project Name",
  "Author": "your name",
+
    "Author": "your name",
  "Version": "1.0.0",
+
    "Version": "1.0.0",
  "Description": "One or two sentences about the mod.",
+
    "Description": "One or two sentences about the mod.",
  "UniqueID": "YourName.YourProjectName",
+
    "UniqueID": "YourName.YourProjectName",
  "EntryDll": "YourDllFileName.dll",
+
    "EntryDll": "YourDllFileName.dll",
  "MinimumApiVersion": "2.9",
+
    "UpdateKeys": []
  "UpdateKeys": []
 
 
}
 
}
</source>
+
</syntaxhighlight>
| <source lang="javascript">
+
| <syntaxhighlight lang="javascript">
 
{
 
{
  "Name": "YourProjectName",
+
    "Name": "Your Project Name",
  "Author": "your name",
+
    "Author": "your name",
  "Version": "1.0.0",
+
    "Version": "1.0.0",
  "Description": "One or two sentences about the mod.",
+
    "Description": "One or two sentences about the mod.",
  "UniqueID": "YourName.YourProjectName",
+
    "UniqueID": "YourName.YourProjectName",
  "MinimumApiVersion": "2.9",
+
    "UpdateKeys": [],
  "UpdateKeys": [],
+
    "ContentPackFor": {
  "ContentPackFor": {
+
        "UniqueID": "Pathoschild.ContentPatcher"
      "UniqueID": "Pathoschild.ContentPatcher", // the ID of required mod
+
    }
      "MinimumVersion": "1.6.0" // optional
 
  }
 
 
}
 
}
</source>
+
</syntaxhighlight>
 
|}
 
|}
  
Line 48: Line 45:
 
! description
 
! description
 
|-
 
|-
| <tt>Name</tt>
+
| <samp>Name</samp>
| The mod name. SMAPI uses this in player messages, logs, and errors. Example: <source lang="javascript">"Name": "Lookup Anything"</source>
+
| The mod name. SMAPI uses this in player messages, logs, and errors. Example: <syntaxhighlight lang="javascript">"Name": "Lookup Anything"</syntaxhighlight>
 
|-
 
|-
| <tt>Author</tt>
+
| <samp>Author</samp>
| The name of the person who created the mod. Ideally this should include the username used to publish mods. Example: <source lang="javascript">"Author": "Pathoschild"</source>
+
| The name of the person who created the mod. Ideally this should include the username used to publish mods. Example: <syntaxhighlight lang="javascript">"Author": "Pathoschild"</syntaxhighlight>
 
|-
 
|-
| <tt>Version</tt>
+
| <samp>Version</samp>
 
| The mod's [http://semver.org/ semantic version]. Make sure you update this for each release! SMAPI uses this for update checks, mod dependencies, and compatibility blacklists (if the mod breaks in a future version of the game). Examples:
 
| The mod's [http://semver.org/ semantic version]. Make sure you update this for each release! SMAPI uses this for update checks, mod dependencies, and compatibility blacklists (if the mod breaks in a future version of the game). Examples:
<source lang="javascript">
+
<syntaxhighlight lang="javascript">
"Version": "1.0"
+
"Version": "1.0.0"
</source>
+
</syntaxhighlight>
<source lang="javascript">
+
<syntaxhighlight lang="javascript">
 
"Version": "1.0.1-beta.2"
 
"Version": "1.0.1-beta.2"
</source>
+
</syntaxhighlight>
 
|-
 
|-
| <tt>Description</tt>
+
| <samp>Description</samp>
| A short explanation of what your mod does (one or two sentences), shown in the SMAPI log. Example: <source lang="javascript">"Description": "View metadata about anything by pressing a button."</source>
+
| A short explanation of what your mod does (one or two sentences), shown in the SMAPI log. Example: <syntaxhighlight lang="javascript">"Description": "View metadata about anything by pressing a button."</syntaxhighlight>
 
|-
 
|-
| <tt>UniqueID</tt>
+
| <samp>UniqueID</samp>
| A unique identifier for your mod. The recommended format is <tt>&lt;your name&gt;.&lt;mod name&gt;</tt>, with no spaces or special characters. SMAPI uses this for update checks, mod dependencies, and compatibility blacklists (if the mod breaks in a future version of the game). When another mod needs to reference this mod, it uses the unique ID. Example: <source lang="javascript">"UniqueID": "Pathoschild.LookupAnything"</source>
+
| A unique identifier for your mod. The recommended format is <samp>&lt;your name&gt;.&lt;mod name&gt;</samp>, with no spaces or special characters. SMAPI uses this for update checks, mod dependencies, and compatibility blacklists (if the mod breaks in a future version of the game). When another mod needs to reference this mod, it uses the unique ID. For this reason, once you've published your mod, do not change this unique ID in future versions of the same mod. Example: <syntaxhighlight lang="javascript">"UniqueID": "Pathoschild.LookupAnything"</syntaxhighlight>
 
|-
 
|-
| <tt>EntryDll</tt> '''or''' <tt>ContentPackFor</tt>
+
| <samp>EntryDll</samp> '''or''' <samp>ContentPackFor</samp>
| <p>All mods must specify either <tt>EntryDll</tt> (for a SMAPI mod) or <tt>ContentPackFor</tt> (for a [[Modding:Content packs|content pack]]). These are mutually exclusive — you can't specify both.</p>
+
| <p>All mods must specify either <samp>EntryDll</samp> (for a SMAPI mod) or <samp>ContentPackFor</samp> (for a [[Modding:Content packs|content pack]]). These are mutually exclusive — you can't specify both.</p>
  
For a SMAPI mod, <tt>EntryDll</tt> is the mod's compiled DLL filename in its mod folder. Example: <source lang="javascript">"EntryDll": "LookupAnything.dll"</source>
+
For a SMAPI mod, <samp>EntryDll</samp> is the mod's compiled DLL filename in its mod folder. Example: <syntaxhighlight lang="javascript">"EntryDll": "LookupAnything.dll"</syntaxhighlight>
  
For a content pack, <tt>ContentPackFor</tt> specifies which mod can read it. The <tt>MinimumVersion</tt> is optional. Example:
+
For a content pack, <samp>ContentPackFor</samp> specifies which mod can read it. The <samp>MinimumVersion</samp> is optional. Example:
<source lang="javascript">
+
<syntaxhighlight lang="javascript">
 
"ContentPackFor": {
 
"ContentPackFor": {
 
   "UniqueID": "Pathoschild.ContentPatcher",
 
   "UniqueID": "Pathoschild.ContentPatcher",
 
   "MinimumVersion": "1.0.0"
 
   "MinimumVersion": "1.0.0"
 
}
 
}
</source>
+
</syntaxhighlight>
 
|}
 
|}
  
===Minimum SMAPI version===
+
===Minimum SMAPI or game version===
The <tt>MinimumApiVersion</tt> fields sets the minimum SMAPI version needed to use this mod. If a player tries to use the mod with an older SMAPI version, they'll see a friendly message saying they need to update SMAPI. This also serves as a proxy for the minimum game version, since SMAPI itself enforces a minimum game version. Example: <source lang="javascript">"MinimumApiVersion": "1.10"</source>
+
The <samp>MinimumApiVersion</samp> and <samp>MinimumGameVersion</samp> field sets the minimum version of SMAPI or Stardew Valley needed to use this mod. If a player tries to use the mod with an older version, they'll see a friendly message saying they need to update it.  
 +
 
 +
For example:
 +
<syntaxhighlight lang="javascript">"MinimumApiVersion": "4.0.0"</syntaxhighlight>
  
 
===Dependencies===
 
===Dependencies===
The <tt>Dependencies</tt> field specifies other mods required to use this mod. If a player tries to use the mod and the dependencies aren't installed, the mod won't be loaded and they'll see a friendly message saying they need to install those. Example:
+
The <samp>Dependencies</samp> field specifies other mods required to use this mod. If a player tries to use the mod and the dependencies aren't installed, the mod won't be loaded and they'll see a friendly message saying they need to install those. For example:
<source lang="javascript">
+
<syntaxhighlight lang="javascript">
 
"Dependencies": [
 
"Dependencies": [
 
   {
 
   {
       "UniqueID": "Entoarox.Framework",
+
       "UniqueID": "SMAPI.ConsoleCommands",
       "MinimumVersion": "1.7.9" // optional. If specified, older versions won't meet the requirement.
+
       "MinimumVersion": "3.8.0" // optional. If specified, older versions won't meet the requirement.
 
   }
 
   }
 
]
 
]
</source>
+
</syntaxhighlight>
  
 
You can mark a dependency as optional. It will be loaded first if it's installed, otherwise it'll be ignored.
 
You can mark a dependency as optional. It will be loaded first if it's installed, otherwise it'll be ignored.
<source lang="javascript">
+
<syntaxhighlight lang="javascript">
 
"Dependencies": [
 
"Dependencies": [
 
   {
 
   {
       "UniqueID": "Entoarox.Framework",
+
       "UniqueID": "SMAPI.ConsoleCommands",
 
       "IsRequired": false
 
       "IsRequired": false
 
   }
 
   }
 
]
 
]
</source>
+
</syntaxhighlight>
  
 
===Update checks===
 
===Update checks===
SMAPI can detect new versions of your mod and alert the user with a link to your mod page. You can enable this by setting the <tt>UpdateKeys</tt> field in your <tt>manifest.json</tt> with one of the following values, which tells SMAPI where to check.
+
SMAPI can detect new versions of your mod and alert the user with a link to your mod page. You can enable this by setting the <samp>UpdateKeys</samp> field in your <samp>manifest.json</samp>, which tells SMAPI where to check.
 
 
{| class="wikitable"
 
|-
 
! mod site
 
! description
 
|- valign="top"
 
| [https://community.playstarbound.com/resources/categories/stardew-valley.22/ Chucklefish]
 
| Make sure you have a mod release page (with a URL containing <tt>/resources/</tt> instead of <tt>/thread/</tt>) and it has a [http://semver.org/ semantic version], then specify the mod ID (the number in the mod page URL). <source lang="javascript">"UpdateKeys": [ "Chucklefish:4250" ]</source>
 
|- valign="top"
 
| [https://www.nexusmods.com/stardewvalley Nexus Mods]
 
| Make sure the Nexus mod has a [http://semver.org/ semantic version], then specify the mod ID (the number in the mod page URL). When creating a new mod on Nexus, the ID is added to the URL after the first step, before you need to upload the file. <source lang="javascript">"UpdateKeys": [ "Nexus:541" ]</source>
 
|- valign="top"
 
| [https://github.com/ GitHub]
 
| Make sure your [https://help.github.com/articles/creating-releases/ GitHub project has at least one release] and the latest release's tag is a [http://semver.org/ semantic version], then specify your GitHub username and project name. <source lang="javascript">"UpdateKeys": [ "GitHub:Pathoschild/LookupAnything" ]</source>
 
|-
 
| [https://www.moddrop.com/sdv/ ModDrop]
 
| Make sure the mod page has a [http://semver.org/ semantic version], then specify the mod ID (the number in the mod page URL). <source lang="javascript">"UpdateKeys": [ "ModDrop:123338" ]</source>
 
|}
 
  
If you set multiple values, SMAPI will check them all and show an alert for the latest version it finds. (If multiple sites have the latest version, it will link to the earlier one in the list.)
+
See [[../Update checks|''update checks'']] for more information.
<source lang="javascript">"UpdateKeys": [ "Chucklefish:4250", "Nexus:541", "GitHub:Pathoschild/LookupAnything" ]</source>
 
  
 
===Anything else===
 
===Anything else===
Any other fields will be stored in the <tt>IManifest.ExtraFields</tt> dictionary, which is available through the [[../#Mod registry|mod registry]]. Extra fields are ignored by SMAPI, but may be useful for extended metadata intended for other mods.
+
Any other fields will be stored in the <samp>IManifest.ExtraFields</samp> dictionary, which is available through the [[../#Mod registry|mod registry]]. Extra fields are ignored by SMAPI, but may be useful for extended metadata intended for other mods.
  
{{modding guide footer
+
[[es:Modding:Guía del Modder/APIs/Manifest]]
|prev = [[Modding:Modder Guide/APIs|SMAPI reference]]
+
[[zh:模组:制作指南/APIs/Manifest]]
|next =
 
}}
 

Latest revision as of 03:09, 8 April 2024

Creating SMAPI mods SMAPI mascot.png


Modding:Index

Every SMAPI mod or content pack must have a manifest.json file in its folder. SMAPI uses this to identify and load the mod, perform update checks, etc. The manifest info is also available to any mod in code (using this.ModManifest for the current mod's manifest, or mod registry for other mods' manifests).

Basic examples

Here's the basic format (see below for details on each field):

For a SMAPI mod For a content pack
{
    "Name": "Your Project Name",
    "Author": "your name",
    "Version": "1.0.0",
    "Description": "One or two sentences about the mod.",
    "UniqueID": "YourName.YourProjectName",
    "EntryDll": "YourDllFileName.dll",
    "UpdateKeys": []
}
{
    "Name": "Your Project Name",
    "Author": "your name",
    "Version": "1.0.0",
    "Description": "One or two sentences about the mod.",
    "UniqueID": "YourName.YourProjectName",
    "UpdateKeys": [],
    "ContentPackFor": {
        "UniqueID": "Pathoschild.ContentPatcher"
    }
}

Fields

Basic fields

All mods should specify the following fields.

field description
Name The mod name. SMAPI uses this in player messages, logs, and errors. Example:
"Name": "Lookup Anything"
Author The name of the person who created the mod. Ideally this should include the username used to publish mods. Example:
"Author": "Pathoschild"
Version The mod's semantic version. Make sure you update this for each release! SMAPI uses this for update checks, mod dependencies, and compatibility blacklists (if the mod breaks in a future version of the game). Examples:
"Version": "1.0.0"
"Version": "1.0.1-beta.2"
Description A short explanation of what your mod does (one or two sentences), shown in the SMAPI log. Example:
"Description": "View metadata about anything by pressing a button."
UniqueID A unique identifier for your mod. The recommended format is <your name>.<mod name>, with no spaces or special characters. SMAPI uses this for update checks, mod dependencies, and compatibility blacklists (if the mod breaks in a future version of the game). When another mod needs to reference this mod, it uses the unique ID. For this reason, once you've published your mod, do not change this unique ID in future versions of the same mod. Example:
"UniqueID": "Pathoschild.LookupAnything"
EntryDll or ContentPackFor

All mods must specify either EntryDll (for a SMAPI mod) or ContentPackFor (for a content pack). These are mutually exclusive — you can't specify both.

For a SMAPI mod, EntryDll is the mod's compiled DLL filename in its mod folder. Example:
"EntryDll": "LookupAnything.dll"

For a content pack, ContentPackFor specifies which mod can read it. The MinimumVersion is optional. Example:

"ContentPackFor": {
   "UniqueID": "Pathoschild.ContentPatcher",
   "MinimumVersion": "1.0.0"
}

Minimum SMAPI or game version

The MinimumApiVersion and MinimumGameVersion field sets the minimum version of SMAPI or Stardew Valley needed to use this mod. If a player tries to use the mod with an older version, they'll see a friendly message saying they need to update it.

For example:

"MinimumApiVersion": "4.0.0"

Dependencies

The Dependencies field specifies other mods required to use this mod. If a player tries to use the mod and the dependencies aren't installed, the mod won't be loaded and they'll see a friendly message saying they need to install those. For example:

"Dependencies": [
   {
      "UniqueID": "SMAPI.ConsoleCommands",
      "MinimumVersion": "3.8.0" // optional. If specified, older versions won't meet the requirement.
   }
]

You can mark a dependency as optional. It will be loaded first if it's installed, otherwise it'll be ignored.

"Dependencies": [
   {
      "UniqueID": "SMAPI.ConsoleCommands",
      "IsRequired": false
   }
]

Update checks

SMAPI can detect new versions of your mod and alert the user with a link to your mod page. You can enable this by setting the UpdateKeys field in your manifest.json, which tells SMAPI where to check.

See update checks for more information.

Anything else

Any other fields will be stored in the IManifest.ExtraFields dictionary, which is available through the mod registry. Extra fields are ignored by SMAPI, but may be useful for extended metadata intended for other mods.