-
Notifications
You must be signed in to change notification settings - Fork 34
Testing and Debugging
With mods enabled, you can open/close the dev console by pressing any of ~, `, *, ', or Shift+8. In the dev console, type help to see the list of commands, or help commandname to see help for a specific command (e.g. help card).
The dev console allows you to quickly test most types of content by immediately spawning it and has a variety of other useful commands too.
If the game crashes, freezes, hangs, or otherwise behaves strangely while testing your mod, you should check the game's logs for any errors.
If you're developing a mod, it's useful to be able to look at the logs immediately when things go wrong. While on the main menu of the game, go to Mod Configurations -> BaseLib and check "Open log window on startup". This makes the log window open automatically whenever you run the game.
Alternatively, you can run the showlog command in the dev console. This immediately opens the log window, and it will stay open until you quit the game, but you will need to run the command again to reopen the log window after restarting.
Logs are also saved to a file. If the game is still open, you can run open logs in the dev console to open your file explorer at the logs directory. Otherwise, you can navigate there yourself. It will normally be at one of the following locations:
- Windows:
%appdata%/SlayTheSpire2/logs - MacOS:
~/Library/Application Support/SlayTheSpire2/logs - Linux:
~/.local/share/SlayTheSpire2/logs
godot.log in this directory contains the most recent logs.
Once you can see the logs, you should check for any lines that mention errors. They will usually reference something in your mod, although not always.
You can refer to this guide on Reading a stack trace to try and understand stack traces of errors you find.
If you want your mod to add information to the log file, you can do this using the Logger field in your MainFile (the template comes with this by default), e.g. MainFile.Logger.Info("Some useful information."). This can be helpful if you have complex or error-prone code; logging details of the steps your code is taking can help narrow down issues.
Create a file named steam_appid.txt in your sts2 directory with the contents 2868840. This allows launching the game without going through Steam.
-
Host: Launch the game with the
-fastmp host_standardcommand line argument. -
Client: Launch the game with the
-fastmp joinargument. After a brief delay, it will join your other game.
To test with more than 2 players, you will additionally need to pass the -clientId argument for the additional clients. The default clientId is 1000. For example, to have a 3rd player join use the arguments -fastmp join -clientId 1001. and -clientId 1002 for the 4th player.
Below are example scripts that run the number of instances specified as a command line argument. You'll most likely have to adjust the path to the sts2 executable.
Windows
setlocal enabledelayedexpansion
start "" "SlayTheSpire2.exe" -fastmp host_standard
set /A NUM_CLIENTS=%1-2
for /L %%i in (0,1,!NUM_CLIENTS!) do (
set /A CID=1000+%%i
start "" "SlayTheSpire2.exe" -fastmp join -clientId !CID!
)Linux/Mac
#!/usr/bin/env bash
./SlayTheSpire2 -fastmp host_standard &
for ((i=0; i<($1-1); i++)); do
cid=$((1000 + i))
./SlayTheSpire2 -fastmp join -clientId "$cid" &
done
waitCreate a file named steam_appid.txt in your sts2 directory with the contents 2868840. This allows launching the game without going through Steam.
In order for breakpoints to work correctly, you need to copy the pdb to the folder where your mod's dll is. You can do it manually, or add the following to the end of your CopyToModsFolderOnBuild Target in your .csproj (assuming you're using the ModTemplate)
<Copy SourceFiles="$(TargetDir)$(TargetName).pdb" DestinationFolder="$(ModsPath)$(MSBuildProjectName)/" />In Rider, go to Run / Debug Configuration > Edit Configurations. Click Add New Configuration (+) > .Net Executable, and fill out the Executable and Working Directory. Then click OK.

In Visual Studio, go to Menu > Debug > Debug Properties and fill out the Executable and Working Directory.

At this point, you should be able to launch sts2 from the configuration you've created.
This will allow you to step into code from other mods or sts2 itself.
In Rider, go to Settings > Build, Execution, Deployment > Debugger > .Net Languages, and enable Enable external source debug

