-
Notifications
You must be signed in to change notification settings - Fork 47
Setup
Important
Familiarity with C# and object-oriented programming are highly recommended if you want to mod Slay the Spire 2. We suggest finding other resources to learn C# first if you're new to programming or to C# specifically, such as a Codeacademy course or a text guide like Essential C#.
These steps will get you started with a project built on top of BaseLib, a community-developed library that helps smooth the modding process.
-
Install a C# IDE. Rider or Visual Studio are common options. Rider is recommended, as Godot requires a .sln file and Visual Studio is moving away from those, making it more difficult to generate a project that uses one. This tutorial will primarily explain things in the context of Rider.
-
Download Dependencies
- Download the latest version of MegaDot (Mega Crit's custom version of Godot)
- As a fallback, you can also use the version of Godot .NET that exactly matches the latest MegaDot version
- Install .NET SDK (9.0 or higher)
- Subscribe to BaseLib on the Steam Workshop. This will put it in a folder under your Steam install, at
Steam/steamapps/workshop/content/2868840/3737335127/BaseLib.- If for some reason that doesn't work, you can download the latest release of BaseLib from GitHub and put it in your Slay the Spire 2 mods folder. (If you're not sure where that is, consult this page.) You can download the
.zipand extract the files or download the.dll,.pck, and.jsonindividually. (This is more complex to set up and means you won't automatically get new versions of BaseLib.)
- If for some reason that doesn't work, you can download the latest release of BaseLib from GitHub and put it in your Slay the Spire 2 mods folder. (If you're not sure where that is, consult this page.) You can download the
- In your IDE, open a terminal (in Rider: first create a new solution as a placeholder, then press
Alt+F12orCtrl+`depending on your keybindings or click the Terminal button in the bottom left
) and run the command dotnet new install Alchyr.Sts2.Templatesto install the template from NuGet (.NET's built-in package manager). If the option to open the terminal isn't there, create a new solution to get it to show up. You can also run this from any command line where the dotnet sdk is available.
- Alternatively, you can download this project from Github and add it as it as a template in Rider by starting from step 7 here.
- Go to
File>New Solutionto create a solution using one of the 3 included templates:
- Slay the Spire 2 Character - a template for creating a new character
- Slay the Spire 2 Content - a template for adding new content (cards, relics, potions, etc.)
- Empty Slay the Spire 2 Mod - a minimal template, for anything else
When creating a template:
- The project name should not contain any spaces
- The format must be
.sln - Check the box for
Put solution and project in same directory - Expand "Advanced Settings" (in Rider) to adjust author and some other options.
- Open the
Directory.Build.propsfile. Find the<GodotPath>property; if your MegaDot install isn't at the default location, change it to match where the executable is (if this is wrong, publishing in step 8 below will not work). Do not put quotes around it. Also, if Slay the Spire 2's path is not found automatically, this is the file to adjust. Try pressing theBuildbutton (Hammer on the top bar, or through the Build menu on bottom left).
If Slay the Spire 2 is not found, you will get an error similar to this Error : Slay the Spire 2 data not found at path '?/steamapps/common/Slay the Spire 2/data_sts2_windows_x86_64'. To fix this, uncomment the <Sts2Path> line and set it to the directory you have StS 2 installed at.
If using the character template and you get an error related to localization, the project is set up correctly.
-
You can change the mod's display name in the mod's manifest
.json. The file will have the same name as the project. Do not modify the id; this determines the names of the files the game will attempt to load. The other values can be modified for the mod you are making; see the mod manifest documentation for details. -
If you are using the character template, you will need to generate the localization for the character. Open the character class in
YourModCode/Character/YourMod.cs. It should have two errors like this; one for "character" localization and one for "ancient" localization.
For each one, push alt+enter and choose "Generate localization", then move the generated text to the appropriate file (localization/eng/characters.json and localization/eng/ancients.json).
Localization can be generated similarly for cards, relics, ancients, and other content. You can find the full list of supported types here.
- For your mod's localization, images, and any other non-code changes to work, you must publish your mod (not just build). To set up publishing, right click the project in the left sidebar and choose
Publish. In Rider, chooseLocal folder. Publish options can be left as default. Publishing will compile your mod's.dll, generate a.pckwith your mod's assets, and copy the mod's files (.dll,.pck, and.json) to Slay the Spire 2's mods folder. If Godot's path is not set correctly inDirectory.Build.propsattempting to publish will give you an error.
Publishing is somewhat slow due to the process of generating the .pck through Godot. If you modify only code files, you can Build instead by clicking the hammer button on the top bar. This will only compile the .dll containing your code and copy it to the mods folder.
Issues with publishing may occur if dotnet on system is not setup properly; can be worked around with DOTNET_ROOT=~/.dotnet (valid path to wherever dotnet is) at start of GodotPublish command.
Warning
You must publish every time you make any non-code changes (localization, images, scenes, etc.) for them to show up.
After building or publishing, you should be able to run the game and see your mod in the mod list (under Settings -> Mod Settings).
You will need more information to develop a mod. Here's what you should start with.
- Note all the generally useful information in Modding Basics
- Learn how to decompile the game and extract game assets and text; seeing how the base game does things is one of the best ways to learn
- Understand how testing and debugging works so you can check if your code works, understand errors, and fix things
- Read through the other reference material linked from the main page, covering specific types of content, external resources, and more
- Error:
[MSB4236] The SDK 'Godot.NET.Sdk/4.5.1' specified could not be found.
Run the following in a terminal
dotnet nuget add source https://api.nuget.org/v3/index.json
- Error:
[MSB4236] The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found.
Go intoFile>Settings> search fortoolsetand changeMSBuild versionto one mentioning rider