Changes

→‎Create a mod: reorganise & tweak to simplify for new developers
Line 42: Line 42:  
# Create a solution with a C# class library project (see [[Modding:IDE reference#create-project|how to]]).
 
# Create a solution with a C# class library project (see [[Modding:IDE reference#create-project|how to]]).
 
# Change the target framework to .NET Framework 4.5 for compatibility with Linux (see [[Modding:IDE reference#set-target-framework|how to]]).
 
# Change the target framework to .NET Framework 4.5 for compatibility with Linux (see [[Modding:IDE reference#set-target-framework|how to]]).
# Delete the <tt>Class1.cs</tt> or <tt>MyClass.cs</tt> file (see [[Modding:IDE reference#delete-file|how to]]).
  −
  −
===Configure the build===
   
# Reference the [https://github.com/Pathoschild/Stardew.ModBuildConfig <tt>Pathoschild.Stardew.ModBuildConfig</tt> NuGet package] (see [[Modding:IDE reference#add-nuget|how to]]).<br /><small>''This will automatically configure your project to load the right modding dependencies for the current platform, so your mod can be built on Linux, Mac, or Windows. It also adds support for debugging the mod in-game.''</small>
 
# Reference the [https://github.com/Pathoschild/Stardew.ModBuildConfig <tt>Pathoschild.Stardew.ModBuildConfig</tt> NuGet package] (see [[Modding:IDE reference#add-nuget|how to]]).<br /><small>''This will automatically configure your project to load the right modding dependencies for the current platform, so your mod can be built on Linux, Mac, or Windows. It also adds support for debugging the mod in-game.''</small>
 
# [https://github.com/Pathoschild/Stardew.ModBuildConfig#simplify-mod-development Configure the build to deploy your mod files automatically].
 
# [https://github.com/Pathoschild/Stardew.ModBuildConfig#simplify-mod-development Configure the build to deploy your mod files automatically].
  −
That's it! Try building the project and make sure you don't get any errors. If you get an error like "failed to find the game install path", see [https://github.com/Pathoschild/Stardew.ModBuildConfig#troubleshoot the package's ''Troubleshooting'' section].
  −
  −
===Add your manifest===
  −
The mod manifest tells SMAPI about your mod.
  −
  −
<ol>
  −
<li>Add a file named <tt>manifest.json</tt> to your project.</li>
  −
<li>Paste this code into the file (replacing the <tt>&lt;...&gt;</tt> placeholders):
  −
<source lang="json">
  −
{
  −
  "Name": "<your project name>",
  −
  "Author": "<your name>",
  −
  "Version": {
  −
      "MajorVersion": 1,
  −
      "MinorVersion": 0,
  −
      "PatchVersion": 0,
  −
      "Build": null
  −
  },
  −
  "Description": "<One or two sentences about the mod>",
  −
  "UniqueID": "<your name>.<your project name>",
  −
  "EntryDll": "<your project name>.dll"
  −
}
  −
</source></li>
  −
</ol>
  −
  −
This will be listed in the console output when the game is launching. (For more info about the version number, see [http://semver.org/ semantic versioning].)
      
===Write the code===
 
===Write the code===
Almost done! Now for the code SMAPI will run.
+
Now for the code SMAPI will run.
    
<ol>
 
<ol>
<li>Add a C# class file called <tt>ModEntry.cs</tt> to your project.</li>
+
<li>Delete the <tt>Class1.cs</tt> or <tt>MyClass.cs</tt> file (see [[Modding:IDE reference#delete-file|how to]]).</li>
 +
<li>Add a C# class file called <tt>ModEntry.cs</tt> to your project (see [[Modding:IDE reference#Add a file|how to]]).</li>
 
<li>Put this code in the file (replace <tt>YourProjectName</tt> with the name of your project):
 
<li>Put this code in the file (replace <tt>YourProjectName</tt> with the name of your project):
 
<source lang="c#">
 
<source lang="c#">
Line 121: Line 92:  
</source></li>
 
</source></li>
 
</ol>
 
</ol>
 +
 +
===Add your manifest===
 +
The mod manifest tells SMAPI about your mod.
 +
 +
<ol>
 +
<li>Add a file named <tt>manifest.json</tt> to your project.</li>
 +
<li>Paste this code into the file (replacing the <tt>&lt;...&gt;</tt> placeholders):
 +
<source lang="json">
 +
{
 +
  "Name": "<your project name>",
 +
  "Author": "<your name>",
 +
  "Version": {
 +
      "MajorVersion": 1,
 +
      "MinorVersion": 0,
 +
      "PatchVersion": 0,
 +
      "Build": null
 +
  },
 +
  "Description": "<One or two sentences about the mod>",
 +
  "UniqueID": "<your name>.<your project name>",
 +
  "EntryDll": "<your project name>.dll"
 +
}
 +
</source></li>
 +
</ol>
 +
 +
This will be listed in the console output when the game is launching. (For more info about the version number, see [http://semver.org/ semantic versioning].)
    
===Try your mod===
 
===Try your mod===
Line 126: Line 122:  
# Run the game through SMAPI.
 
# Run the game through SMAPI.
   −
The mod so far will just send a message to the console window whenever you press a key in the game. If that didn't work, something went wrong. Try reviewing the above instructions, or [[#help|ask for help]]. :)
+
The mod so far will just send a message to the console window whenever you press a key in the game.
 +
 
 +
===Troubleshooting===
 +
If building the mod doesn't work:
 +
* If you see an error like "failed to find the game install path", see [https://github.com/Pathoschild/Stardew.ModBuildConfig#troubleshoot this page for more info].
 +
* Try reviewing the above steps to make sure you didn't skip something.
 +
* If all else fails, [[#help|ask for help]]. :)
    
==Mod APIs==
 
==Mod APIs==
translators
8,404

edits