-
Notifications
You must be signed in to change notification settings - Fork 50
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 and reduce boilerplate.
We recommend installing Rider because this tutorial uses Rider for its examples and screenshots. If you have experience writing C# and prefer another IDE, feel free to use that instead (If you do use another IDE, note that Godot requires a .sln file, not .slnx).
- Download the latest version of MegaDot (Mega Crit's custom version of the Godot game engine)
- 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. It will install in a folder in your Steam library, 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 BaseLib won't automatically update.)
- 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
Open a terminal and run the following command:
dotnet new install Alchyr.Sts2.Templates
In Rider: first create a new solution as a placeholder, then click the Terminal button in the bottom left
or use a keybind to open the terminal. If the option to open the terminal isn't there, create a new solution to get it to show up.
- Alternatively, you can download this project from Github and add it as it as a template in Rider by starting from step 7 here.
In Rider, go to File > New Solution to 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
If not using Rider
You can run the following command in a terminal to create a project from one of the templates
dotnet new alchyrsts2mod --ModAuthor !YourName -o !ModName
Replace !YourName with your name and !ModName with the name of your mod (don't include the !). Don't use spaces or underscores in your mod name. Replace alchyrsts2mod with alchyrsts2charmod for a character mod, or alchyrsts2contentmod for a content mod. To see all available options, run dotnet new alchyrsts2mod --help.
When creating a solution:
- Check the box for
Put solution and project in same directory - The project name should not contain any spaces
- The format must be
.sln - Expand
Advanced Settings(in Rider) to adjust author and some other options.
Open the Directory.Build.props file. Find the <GodotPath> property. Change it to where you installed MegaDot/Godot. Make sure it points to an executable file (on Windows, it will end in .exe). Do not put quotes around it.
Try pressing the Build button (Hammer icon on the top bar).
If Slay the Spire 2 is not installed at the default location, 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 change 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 (otherwise, skip this step). 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 (YourMod/localization/eng/characters.json and YourMod/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.
Warning
You must publish your mod to a local folder every time you make any non-code changes (text, images, scenes, etc.) for them to show up.
For your mod's text, images, and any other non-code changes to work, you must publish your mod. Just pressing Build is not enough. To set up publishing, right click the project in the left sidebar and choose Publish.
In Rider, choose Local folder. Publish options can be left as default.
Publishing will compile your mod's .dll, generate a .pck with your mod's assets, and copy the mod's files (.dll, .pck, and .json) to Slay the Spire 2's mods folder so that the game loads it. If Godot's path is not set correctly in Directory.Build.props attempting to publish will give you an error (see step 5).
Publishing is slightly slower than building due to the additional process of generating the .pck through Godot. If you modify only .cs 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. If you make any changes to other files, you must publish for them to show up.
After 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
-
Publish doesn't work
- Add
DOTNET_ROOT=~/.dotnet(valid path to wherever dotnet is) at start of GodotPublish command.
- Add
-
Very long error that starts with
Godot.Bridge.CSharpInstanceBridge.Calland has a lot ofSystem.ArgumentException: Value does not fall within the expected range. at MonoMod.Core.Interop.CoreCLR.V60.InvokeCompileMethod(IntPtr functionPtr, IntPtr thisPtr, IntPtr corJitInfo, CORINFO_METHOD_INFO* methodInfo, UInt32 flags, Byte** nativeEntry, UInt32* nativeSizeOfCode)- Either enable publicizing the StS 2 assembly (by going to your csproj file, finding the
<Publicize Include="sts2"line, and changingFalsetoTrueon the line above it) or remove the packageKrafs.Publicizerfrom your project (you can do this from NuGet in Rider)
- Either enable publicizing the StS 2 assembly (by going to your csproj file, finding the
-
Error:
System.ArgumentException: Undefined resource string ID:0x80070057- Same as above, either enable publicizing or remove
Krafs.Publicizerfrom your project
- Same as above, either enable publicizing or remove