Modding:Preparing For Code Mods: Difference between revisions

From Vintage Story Wiki
mNo edit summary
(Marked this version for translation)
Line 3: Line 3:
__TOC__
__TOC__


<translate>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 [[Modding:Creating A Code Mod|Creating a Code Mod]]. For more information on what can be achieved with a code mod, see [[Modding:Code Mods|Code Mods]].
<translate><!--T:1-->
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 [[Modding:Creating A Code Mod|Creating a Code Mod]]. For more information on what can be achieved with a code mod, see [[Modding:Code Mods|Code Mods]].


<!--T:2-->
'''This tutorial is suitable for Windows users'''. If you are using a differing operating system, please view the older [[Modding:Setting up your Development Environment|Setting up your Development Environment]] tutorial page.
'''This tutorial is suitable for Windows users'''. If you are using a differing operating system, please view the older [[Modding:Setting up your Development Environment|Setting up your Development Environment]] tutorial page.


== Installing an IDE ==
== Installing an IDE == <!--T:3-->
When developing a code mod, it is extremely important to choose a suitable IDE. For Vintage Story, it is highly recommended that you use [https://visualstudio.microsoft.com/vs/community/ 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 [https://learn.microsoft.com/en-us/visualstudio/install/modify-visual-studio?view=vs-2022 these steps].   
When developing a code mod, it is extremely important to choose a suitable IDE. For Vintage Story, it is highly recommended that you use [https://visualstudio.microsoft.com/vs/community/ 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 [https://learn.microsoft.com/en-us/visualstudio/install/modify-visual-studio?view=vs-2022 these steps].   


<!--T:4-->
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 [[Modding:Setting up your Development Environment|Setting up your Development Environment]] tutorial page.
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 [[Modding:Setting up your Development Environment|Setting up your Development Environment]] tutorial page.


== Installing .NET 7.0 SDK ==
== Installing .NET 7.0 SDK == <!--T:5-->
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.''
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.''


<!--T:6-->
Download and install the latest [https://dotnet.microsoft.com/en-us/download/dotnet/7.0 .NET 7.0 SDK], ensuring you select the version that is correct for you. This will likely be the ''Windows x64'' version.
Download and install the latest [https://dotnet.microsoft.com/en-us/download/dotnet/7.0 .NET 7.0 SDK], ensuring you select the version that is correct for you. This will likely be the ''Windows x64'' version.


<!--T:7-->
When the SDK has finished installing, it is recommended to check it has been configured correctly. Launch a command prompt in Windows, either by searching for '<nowiki/>''cmd''<nowiki/>' or '''powershell''<nowiki/>' in Windows' search bar, and enter the following command:<syntaxhighlight lang="powershell">
When the SDK has finished installing, it is recommended to check it has been configured correctly. Launch a command prompt in Windows, either by searching for '<nowiki/>''cmd''<nowiki/>' or '''powershell''<nowiki/>' in Windows' search bar, and enter the following command:<syntaxhighlight lang="powershell">
dotnet --list-sdks
dotnet --list-sdks
Line 26: Line 31:
|}
|}


== Creating an Environment Variable ==
== Creating an Environment Variable == <!--T:8-->
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.
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.


<!--T:9-->
Firstly, you need to open 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''<nowiki/>'. If you do not have a shortcut, but have installed Vintage Story to the default install location, it will be found in your appdata folder. You can find this folder by using [https://www.minitool.com/data-recovery/how-find-appdata-folder.html#:~:text=You%20can%20directly%20open%20the,%25appdata%25%20and%20press%20Enter. this method]. If you have installed it elsewhere, you will need to find this folder in the file explorer.
Firstly, you need to open 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''<nowiki/>'. If you do not have a shortcut, but have installed Vintage Story to the default install location, it will be found in your appdata folder. You can find this folder by using [https://www.minitool.com/data-recovery/how-find-appdata-folder.html#:~:text=You%20can%20directly%20open%20the,%25appdata%25%20and%20press%20Enter. this method]. If you have installed it elsewhere, you will need to find this folder in the file explorer.


<!--T:10-->
The opened folder should contain the '<nowiki/>''assets''<nowiki/>', '<nowiki/>''mods''<nowiki/>', and '<nowiki/>''lib''<nowiki/>' folders. Ensure you are '''not''' in the '''VintageStoryData''<nowiki/>' folder.
The opened folder should contain the '<nowiki/>''assets''<nowiki/>', '<nowiki/>''mods''<nowiki/>', and '<nowiki/>''lib''<nowiki/>' folders. Ensure you are '''not''' in the '''VintageStoryData''<nowiki/>' folder.


<!--T:11-->
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'.
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'.
[[File:OpenVintageStoryFolderInPowershell.png|center|frameless|388x388px]]
[[File:OpenVintageStoryFolderInPowershell.png|center|frameless|388x388px]]
Line 47: Line 55:
When you have set a new environment variable, it is recommended to restart your PC. This will ensure that all programs are using your updated environment variables.
When you have set a new environment variable, it is recommended to restart your PC. This will ensure that all programs are using your updated environment variables.


== Installing Modding Templates ==
== Installing Modding Templates == <!--T:12-->
The final step is to install the mod templates. These mod templates will automatically setup your mod for you in Visual Studio, automatically adding any libraries and code that is needed to get your mods up and running.\
The final step is to install the mod templates. These mod templates will automatically setup your mod for you in Visual Studio, automatically adding any libraries and code that is needed to get your mods up and running.\


<!--T:13-->
Open a powershell command line, paste the following, and press enter to run it. This execution should only take a few seconds, as it is a very small file.<syntaxhighlight lang="powershell">
Open a powershell command line, paste the following, and press enter to run it. This execution should only take a few seconds, as it is a very small file.<syntaxhighlight lang="powershell">
dotnet new install VintageStory.Mod.Templates
dotnet new install VintageStory.Mod.Templates
</syntaxhighlight>This is where everything comes together. Your dotnet installation will download the Vintage Story mod templates from NuGet (an online package manager for .NET), and install the templates to be used with Visual Studio.
</syntaxhighlight>This is where everything comes together. Your dotnet installation will download the Vintage Story mod templates from NuGet (an online package manager for .NET), and install the templates to be used with Visual Studio.


=== Test your template installation ===
=== Test your template installation === <!--T:14-->
To ensure that the template has installed correctly, launch Visual Studio and select 'Create a new project'. In the furthest-right drop down list ('<nowiki/>''All project types'''), find 'Vintage Story' in the list.
To ensure that the template has installed correctly, launch Visual Studio and select 'Create a new project'. In the furthest-right drop down list ('<nowiki/>''All project types'''), find 'Vintage Story' in the list.
[[File:VintageStoryTemplatesInVisualStudio.png|center|frameless|571x571px]]
[[File:VintageStoryTemplatesInVisualStudio.png|center|frameless|571x571px]]




<!--T:15-->
If it exists, and displays two projects, then your template has successfully installed and you are ready to start making code mods. Congratulations!
If it exists, and displays two projects, then your template has successfully installed and you are ready to start making code mods. Congratulations!


<!--T:16-->
If 'Vintage Story' does not exist in the project types, or there are no projects listed under this category, try restarting your PC and looking again. If there is still nothing, run the above command again.
If 'Vintage Story' does not exist in the project types, or there are no projects listed under this category, try restarting your PC and looking again. If there is still nothing, run the above command again.


== Next Steps ==
== Next Steps == <!--T:17-->
Now that you have completed this tutorial, you can begin creating as many code mods as you wish. Move on to [[Modding:Creating A Code Mod]] to setup and customize your first mod!
Now that you have completed this tutorial, you can begin creating as many code mods as you wish. Move on to [[Modding:Creating A Code Mod]] to setup and customize your first mod!
</translate>
</translate>
{{Navbox/codemodding}}
{{Navbox/codemodding}}