Modding:Preparing For Code Mods

From Vintage Story Wiki
Revision as of 10:13, 20 May 2024 by Nateonus (talk | contribs) (Env Variable)
Other languages:
  • English

This page was last verified for Vintage Story version 1.19.8.


There is a small number of steps that must be followed before you can create a code mod. These steps only have to be done once - If you have completed this tutorial before, you may start from Creating a Code Mod. For more information on what can be achieved with a code mod, see Code Mods.

This tutorial is suitable for Windows users. If you are using a differing operating system, please view the older Setting up your Development Environment tutorial page.

Installing an IDE

When developing a code mod, it is extremely important to choose a suitable IDE. For Vintage Story, it is highly recommended that you use Visual Studio Community - A free and powerful development environment that is used by the Vintage Story team to develop the game. When installing Visual Studio, you should also install the .NET desktop development workload, which can be done during installation or by following these steps.

Although some other IDEs are suitable, this tutorial will assume you are using Visual Studio. If you cannot use Visual Studio, please view the older Setting up your Development Environment tutorial page.

Installing .NET 7.0 SDK

An SDK (Software Development Kit) is used to help you develop programs and code for specific platforms. Since Vintage Story relies on the .NET 7.0 SDK, it is important that you download and install this too. This SDK is sometimes referred to as dotnet.

Download and install the latest .NET 7.0 SDK, ensuring you select the version that is correct for you. This will likely be the Windows x64 version.

When the SDK has finished installing, it is recommended to check it has installed. Launch a command prompt in Windows, either by searching for 'cmd' or 'powershell' in Windows' search bar, and enter the following command:

dotnet --list-sdks

This should give you a list of installed SDKs. If there is an entry that starts with 7.0., then you may continue.

SDK not showing or getting an error?
Restart your PC, and redo the given command in the command prompt or powershell. If it is still not visible, then repeat the installation for this section.

Creating an Environment Variable

An Environment Variable is a value that can be used by numerous applications across your PC. Because the modding environment is separate to the game itself, you need to create a new environment variable that links to the path of your game.

Firstly, you need to open your Vintage Story in your file explorer. If you have a shortcut to Vintage Story on your Desktop, you can right-click it and select 'Open file location'. If you do not have a shortcut, and have installed Vintage Story to the default install location, it will be found in your appdata folder. You can find this folder by using this method. If you have installed it elsewhere, you will need to find this folder in the file explorer.

The opened folder should contain the 'assets', 'mods', and 'lib' folders.

When you have your game folder open in Windows file explorer, you need to open this folder in powershell. Ensure you do not have a file or folder selected, and click 'File' in the menu bar, then click 'Open Windows PowerShell'.

OpenVintageStoryFolderInPowershell.png

Powershell will open with your file path. Ensure that the file path stated does not include the 'assets', 'mods', or 'lib' folders. Paste the following line into powershell, and press enter to run it.

[Environment]::SetEnvironmentVariable("VINTAGE_STORY", ($pwd.path), "User")

This will create the environment variable called "VINTAGE_STORY", and set its value to be the current working directory (the Vintage Story folder). The "user" parameter simply stores this variable as a user-only environment variable, meaning other users on your PC will not be able to use this variable.

Test your environment variable
To ensure your environment variable has been created correctly, in the opened powershell, run the following command:
echo $env:VINTAGE_STORY
This should print the direct path to your vintage story directory. If it does not, then repeat this section.
Icon Sign.png

Wondering where some links have gone?
The modding navbox is going through some changes! Check out Navigation Box Updates for more info and help finding specific pages.

Modding
Modding Introduction Getting Started Theme Pack
Content Modding Content Mods Developing a Content Mod Basic Tutorials Intermediate Tutorials Advanced Tutorials Content Mod Concepts
Code Modding Code Mods Setting up your Development Environment
Property Overview ItemEntityBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsWorld properties
Workflows & Infrastructure Modding Efficiency TipsMod-engine compatibilityMod ExtensibilityVS Engine
Additional Resources Community Resources Modding API Updates Programming Languages List of server commandsList of client commandsClient startup parametersServer startup parameters
Example ModsAPI DocsGitHub Repository