Setting up your Development Environment
When you are ready to begin coding mods for Vintage Story, you probably would want to set up a development environment that simplifies the process of coding and testing your creations. But if you feel hardcore, you can even create your code mods with your most basic text editor. The game engine will compile your raw source files when it finds them in your mod folder. Otherwise continue to read this tutorial.
First of all download VintageStory and make sure you have installed the newest version of the game, otherwise errors may occur.
Install Development Tool
VintageStory is developed in C#. Programming is most efficiently done in an IDE (integrated development environment). Let's install one!
VintageStory is developed using VisualStudio. You can get VisualStudio Community for free here. Installation should be simple and straight forward to do, but depending on your internet connection it may take a while.
There are multiple programs you could use. The following tutorials will use MonoDevelop, but you can also use VisualStudio Code which is a light-weight, cross-platform development tool (tutorial). If you want to use MonoDevelop, just stay here and continue the tutorial.
1. Install FlatPak
It is required to install MonoDevelop so if you already have FlatPak then you can skip this step. FlatPak have their own guides of how to install it for many distributions here.
2. Install MonoDevelop
Simply open up a terminal and run the following command:
flatpak install --user --from https://download.mono-project.com/repo/monodevelop.flatpakref
This might take a few minutes depending on your internet connection. (The latest version at the time of writing was around 275MB.) To open up MonoDevelop enter
flatpak run com.xamarin.MonoDevelop in the terminal.
Download and install VisualStudio for Mac here. Unfortunately nobody in our team has a mac, so we don't know for sure if the following tutorials work on mac without any problems.
Project Setup (SRC)
The source mod system lets you build mods that ship with source code that is compiled during run-time by the modloader engine. This has the great advantage of being open and easy to modify on the run but also comes with 2 major disadvantages. Up until game version 1.6.x you only have a hardcoded list of library references available to you (System.dll, System.Core.dll, System.Drawing.dll, System.Xml.dll, System.Net.Http.dll, VintagestoryAPI.dll, Newtonsoft.Json.dll, protobuf-net.dll, Tavis.JsonPatch.dll, cairo-sharp.dll), any other reference will not get loaded and thus your mod would fail to compile. The second major disadvantage, affecting all game versions, is that the inbuilt source code compiler can only compile code only up until C# 6.0, so newer language feature are not supported. If either of these disadvantages are a showstopper to you, we advice you to build a compiled mod.
Get the Modtemplate
To get started download the VSModTemplate solution (here). Now you simply need to extract the zip archive to your desired place:
VSMods and double click
VSMods.sln (only works if VisualStudio is installed). Alternatively you can also start VisualStudio hit
Open Project/ Solution, navigate to the extracted folder and select
But before you can start to work, you have to setup the ModTools first.
The ModTools allow you to do various tasks rather easily by typing in a command. Each platform requires a different way to start it. Please note, the mod tools have only been tested with Visual Studio and MonoDevelop, but they are not required to mod the game, it merely simplifies some of the tasks.
Open a terminal and navigate to this folder and enter
setup [optional path]
Before doing anything else you have to setup your workspace. Just type in
setup and it will automatically try to locate your VintageStory installation directory. If it cannot find it, you will be asked to type in the full path. Once you have entered your path, it will update your project files so you can start to work with it. Now open the project again and run your first test by hitting
start . If everything has been done correctly VintageStory should start.
Adds a new mod project to your workspace, also generates an
src folder and a
modinfo.json file. The mod will be added to your visual studio solution and will be loaded by VintageStory. Make sure to fill in all additional information in
Before executing, make sure your project is closed, otherwise you might run into some difficulties. Running this command will delete the given mod completely (irreversible).
Creates a mod zip file and places it in
/releases/<modid>/<modid>_v<modversion>.zip. This file is ready for use and can be shared with other people.
Packs all mods in your workspace at once.
Project Setup (DLL)
A convenient setup system for dll mods is not finished yet, please refer to the samples mod repository until then: https://github.com/anegostudios/vsmodexamples