Home - Monster-Train-2-Modding-Group/Trainworks-Reloaded GitHub Wiki
Welcome to the Trainworks-Reloaded wiki!
For the easiest setup experience, we highly recommend using GitHub Codespaces, however you may do these steps locally by installing the command utilities and saving secrets as environment variables and edit with Visual Studio or another IDE.
- Go on to Github and Register an Account if you do not already have one.
- Go to your GitHub account and click the + icon in the top right corner.
- Select New repository.
- Choose a suitable name for your repository (e.g., MyModProject).
- Select Public as the visibility setting.
- Be sure to Initialize the github repo with a README file if you intend on using a github codespace to develop.
- Go to thunderstore.io.
- Click Sign Up and create an account.
- Once your account is created, log in and create a Namespace for your mods. Go to Settings → Teams → Create Team
- Save your Namespace name, as you'll need it during the cookiecutter setup.
We need to Generate a Personal Access Token in order to provide access to Github Packages Repository
- On Github, Click on your Profile, Go to Settings → Developer Settings → Personal Access Tokens.
- Generate a new token (classic) with the following permissions:
- read:packages
- public_repo
- Copy the generated token securely.
- In your GitHub Repo, go to Settings → Secrets and Variables → Codespaces → New repository secret
- Create a new secret called GH_AUTH_TOKEN and assign it the token you just generated in step 2.
If your codespace is open before making the Codespace Secrets, Rebuild it to get the new secret variable.
- Go to the Code tab in your repository.
- Click Open Codespace.
Locate your Codespace terminal, run:
pip install cookiecutter
Run the following command to set up your mod template:
cookiecutter https://github.com/Monster-Train-2-Modding-Group/Mod-Template.git
- During Setup:
- It will prompt you for a Namespace on Thunderstore. Use the Namespace you created earlier. If you skip this step, you may need to customize the pipelines and thunderstore.toml later.
- After completing the command, move the generated files out of the subfolder and into the root directory of your repository. (You should be able to select the files in the right and copy them into the root directory).
Again skip this step if you aren't using a github codespace.
- Access the VS Code Command Palette with Shift+Command+P (Mac) or Ctrl+Shift+P (Windows/Linux).
- Start typing "Rebuild" and select Codespaces: Rebuild Container.
- The codespace will be rebuilt with the changes pulled in from our template repository. This step takes a minute and your codespace will restart.
If you are running Visual Studio locally, you should be able to build the solution and the files will be in the usual place. You can run the command below in a terminal if you want.
If you are in a codespace Run the following in the terminal in order to build your mod:
dotnet nuget update source --username $GITHUB_USER --password $GH_AUTH_TOKEN monster-train-packages --store-password-in-clear-text
then
dotnet build -c Release --output ./dist
If everything works a dist folder is created (don't commit this folder) containing your mod. The Modding Template created from the cookiecutter step makes a mod that changes several aspects of the starter card Firestarter
- Firestarter costs 0 ember to play
- It has the consume keyword
- It deals 5 damage
- It has it card art replaced
- Card description text was updated to reflect the changes.
- For manually testing your mod, it requires installing BepinEx. Download that from here
- Copy the contents of that zip file to
C:\Program Files (x86)\Steam\steamapps\common\Monster Train 2
- Run Monster Train 2 one to get Bepinex configs loaded.
- You may wish to check
C:\Program Files (x86)\Steam\steamapps\common\Monster Train 2\BepinEx\config\BepInEx.cfg
which contains configuration for BepinEx. I at least would recommend enabling the console in theLogging.Console
section. Additionally if anything goes wrong note theLogOutput.log
file which contains all of the logs if you missed them in the Console.
- Be sure to download the latest release
- Extract the contents to
C:\Program Files (x86)\Steam\steamapps\common\Monster Train 2\BepinEx\plugins\Trainworks
- If you are using a github codespace right click on dist/.dll and download it. This is your compiled Plugin that defines your mod. You only need to rebuild this when adding/removing json files in the Plugin.cs file or whenever you edit this file (or add other .cs files to the project).
- You will also need the json files in the dist/json directory.
- Copy the dll file to
C:\Program Files (x86)\Steam\steamapps\common\Monster Train 2\BepinEx\plugins
. - Copy
plugin.json
andglobals.json
toC:\Program Files (x86)\Steam\steamapps\common\Monster Train 2\BepinEx\plugins\json
- Start the game and start a run with Pyreborne (Fenix) and if everything worked you should see his starter card has changed.
Be sure to check the tutorials section for a more in-depth guide on how to make content.
Mods in Monster Train 2 consists of code (Plugin.cs and other .cs files), configuration for game data (the json files in the json/ folder), and assets (images and other stuff in the textures/ folder).
- Whenever you modify the .cs files you must recompile your mod (repeating Step 9 in the setup with the dotnet build).
- Whenever you add or remove .json files that requires adding them to your Plugin.cs file on the
AddMergedJsonFile
line. This also means you need to recompile your mod as per 1. above. Important Be sure that you are editing the json files in theMyModNameHere.Plugin/json
folder and not thedist/json
folder as the latter will be overwritten when you build your mod. - Editing .json files or adding/removing assets does not require you to recompile the mod.
Everything in the codespace is in a github repository (if you don't know what a repository is there's several tutorials on that). In order to work with our pipelines the code must be committed to the repository.
In the codespace press Ctrl+Shift+G to access the source control options. Here you can commit your code to the repository. Make sure the mod builds before doing this. You will need to learn how to commit your code to the repository in order for our pipelines to release your mod when you have completed it.
For those working in the github codespace. It can get cumbersome having to copy every file everytime you make a build. You can easily zip up the dist folder and just download that and extract the zip folder to Bepinex/plugins on your computer.
This command will create a zip file for you just run this command in the terminal zip dist.zip -r dist
Be sure not to commit the dist.zip file.
You are now set up and can develop your mod. Remember when testing your mod not to do anything online with mods enabled. You can delete the contents of the BepinEx plugins folder to remove the manually installed mods.
IMPORTANT Be sure to keep up to date with the Trainworks Reloaded releases latest for new features / bugfixes. If there is a new version released, be sure to update the dependencies in your csproj file
<PackageReference Include="TrainworksReloaded.Base" Version="Version string here" />
If you are in a codespace it should pull the new version next time you build.
Only follow these steps when your mod is done and ready to be published, once you follow these steps the mod will be available to install via thunderstore.
- Check Trainworks releases (and any dependencies) latest and make sure it matches the version specified in your csproj file.
- Test against the latest version, be sure to check the
Bepinex/LogOutput.log
file and address any warning or error log messages related to your log.
- Go to thunderstore.io, go to Settings → Teams → Your Team → Service Accounts
- Add a Service Account
- Give it a Nickname
- Save the generated token.
- In your GitHub Repo, go to Settings → Secrets and Variables → Actions → New repository secret
- Create a secret named TCLI_AUTH_TOKEN with the value of the generated token.
- Create another secret named GH_AUTH_TOKEN with the value of the token generated in step 2. If you don't have it it was used as a codespace secret in step 4.
- Choose a Semvar Version. https://semver.org/
- Edit
thunderstore.toml
and update versionNumber to match your version. Be sure to properly edit dependencies if you are depending on another mod. - Create a Git Tag, either through github.com or by using
git tag <version>
and thengit push origin tag <version>
- Github Actions should automatically run and publish to thunderstore.io
If the github action fails feel free to send a link to the failed run in the Shiny Shoe discord #mt1-modding (or equivalent) channel.