Set up your tModLoader mods using Microsoft Visual Studio
Last update: 26th of September, 2018
Table of contents:
1. Prerequisites
2. Introduction
3. How-to setup your project in MVS
4. How-to setup your project files
Prerequisites
tl;dr
Make sure you have....
Introduction
tl;dr
THIS IS THE FASTEST WAY
tl;dr
How-to setup your solution (all your mods) in MVS
tl;dr
Final words
Note for MVS 2015: Also creates an invisible .vs folder inside which will show on the build tab, I could ask @bluemagic123 to remove it from the build list but for now simply ignore it.
Instead, you can now list the full .vs in your buildIgnore property inside build.txt like so: buildIgnore = .vs\*
This tutorial is mainly for setting up your mod in MVS, not how to create stuff. So I only included the basics here: your main file and some item .cs files.
Once tModLoader becomes bigger I will create seperate tutorials on how to create stuff. Don't bother asking too much about that here.
Get started with C# (tutorials): (some things I used!)
http://www.tutorialspoint.com/csharp/
http://csharp.net-tutorials.com/
http://www.homeandlearn.co.uk/csharp/csharp.html
Brackeys Youtube C# Series (series)
Special thanks:
If you have any questions, feel free to ask! Make sure you know about C# before asking dumb questions! Really!
- Jofairden
Last update: 26th of September, 2018
Table of contents:
1. Prerequisites
2. Introduction
3. How-to setup your project in MVS
4. How-to setup your project files
Prerequisites
tl;dr
Make sure you have....
- ...the latest tModLoader installed (offical thread)
- ...the latest Microsoft .NET Framework installed (offical .net site)
- ...the Microsoft XNA Framework installed (you have this if you are able to play Terraria)
- ...the Microsoft XNA Framework files ready (download attachment)
- ...Microsoft Visual Studio (community = free) installed with the C# workspace (official MVS site)
- ...C# knowledge
Introduction
tl;dr
- MVS is a workspace for many different (Windows) languages, such as C#. It also has IntelliSense built in which can auto-complete sentences and find and display relationships for you. It will also check your code for errors.
- In this tutorial we work with Microsoft Visual Studio Community 2015, so some instructions below might be a little bit different if you use a different version.
- This tutorial is for people with C# knowledge. Please follow basic C# tutorials before you attempt this.
THIS IS THE FASTEST WAY
tl;dr
- Go here: http://javid.ddns.net/tModLoader/generator/ModSkeletonGenerator.html
- Enter the required details. Do NOT use spaces for the mod name.
- Unzip the zip to the Terraria documents
- Mac: /Users/account/Library/Application Support/Terraria/ModLoader/Mod Sources
- Linux: ~/.local/share/Terraria OR $XDG_DATA_HOME/Terraria/ModLoader/Mod Sources
- Windows: %UserProfile%\Documents\My Games\Terraria\ModLoader\Mod Sources
- Mac: /Users/account/Library/Application Support/Terraria/ModLoader/Mod Sources
- The build.txt is messed up, use the following and change to your needs:
-
Code:
author = bluemagic123 version = 0.8.1 displayName = Example Mod homepage = http://forums.terraria.org/index.php?threads/1-3-tmodloader-a-modding-api.23726/ hideCode = false hideResources = false includeSource = true buildIgnore = *.csproj, *.user, obj\*, bin\*, .vs\* includePDB = true
- Start working on your mod!
- You can use the .csproj file to work using Microsoft Visual Studio
How-to setup your solution (all your mods) in MVS
tl;dr
FULL SETUP (SOLUTION + PROJECT)
- File --> New --> Project (CTRL + SHIFT + N)
- Templates --> Other Project Types --> Visual Studio Solutions --> Blank Solution
- ! Name: Mod Sources
- Locations: c:\users\yourusernamehere\documents\My Games\Terraria\ModLoader
- Uncheck: Add to source control
- ! Name: Mod Sources
- Open the Solution Explorer
- View --> Solution Explorer (CTRL + W, S)
- Right click Mod Sources --> Add --> New Project --> Visual C# --> Windows --> Classic Desktop --> Empty Project
- Name: Whatever the name of your mod is
- Location: leave the location as is
- Add the Example Mod (from the original tML thread) to the folder of your project (documents/My Games/ModLoader/Mod Sources/ExampleMod)
- Click the 'Show all Files' button in the Solution Explorer
- Right click file --> Include file in project
- Rename classes, namespaces, filenames etc. to your needs
- Uncollapse your project, right click 'References' --> Add Reference --> Browse --> Select XNA Framework .dll Files and Terraria.exe
- Before you hit 'OK' make sure the checkbox behind the files are checked!
- If your mod uses any additional dllReferences (Documents\My Games\Terraria\ModLoader\dllReferences) you will need to include those files the same way
SAVING YOUR MOD (PROJECT)
- File --> Save (CTRL + S) or File --> Save All (CTRL + SHIFT + S)
- Build your mod using the in-game menu
ADDING A NEW MOD (PROJECT)
- Right click Mod Sources --> Add --> New Project --> Visual C# --> Windows --> Classic Desktop --> Empty Project
- Name: Whatever the name of your mod is
- Location: leave the location as is
ADDING A NEW REFERENCE
- Right click 'References' --> Add Reference --> Browse --> Select your reference
Final words
Instead, you can now list the full .vs in your buildIgnore property inside build.txt like so: buildIgnore = .vs\*
This tutorial is mainly for setting up your mod in MVS, not how to create stuff. So I only included the basics here: your main file and some item .cs files.
Once tModLoader becomes bigger I will create seperate tutorials on how to create stuff. Don't bother asking too much about that here.
Get started with C# (tutorials): (some things I used!)
http://www.tutorialspoint.com/csharp/
http://csharp.net-tutorials.com/
http://www.homeandlearn.co.uk/csharp/csharp.html
Brackeys Youtube C# Series (series)
Special thanks:
- @blushiemagic (original author of tML)
- Terraria team for these awesome header seperators
- Microsoft for the creation of MVS
If you have any questions, feel free to ask! Make sure you know about C# before asking dumb questions! Really!
- Jofairden
Attachments
Last edited: