Modding:Preparing For Code Mods: Difference between revisions

From Vintage Story Wiki
m
Line 22: Line 22:


<!--T:7-->
<!--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
</syntaxhighlight>This should give you a list of installed SDKs. If there is an entry that starts with ''7.0.,'' then you may continue.
</syntaxhighlight>This should give you a list of installed SDKs. If there is an entry that starts with ''7.0.,'' then you may continue.
Line 38: Line 38:


<!--T:10-->
<!--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 notin theVintageStoryData'' folder.


<!--T:11-->
<!--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]]
Powershell will open with your current file path. Ensure that the file path stated does not include the '<nowiki/>''assets''<nowiki/>', '<nowiki/>''mods''<nowiki/>', or '''lib''<nowiki/>' folders. Paste the following line into powershell, and press enter to run it.<syntaxhighlight lang="powershell">
PowerShell will open with your current file path. Ensure that the file path stated does not include the '<nowiki/>''assets''<nowiki/>', '<nowiki/>''mods''<nowiki/>', or '''lib''<nowiki/>' folders. Paste the following line into PowerShell, and press enter to run it.<syntaxhighlight lang="powershell">
[Environment]::SetEnvironmentVariable("VINTAGE_STORY", ($pwd.path), "User")
[Environment]::SetEnvironmentVariable("VINTAGE_STORY", ($pwd.path), "User")
</syntaxhighlight>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.
</syntaxhighlight>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.
Line 59: Line 59:


<!--T:13-->
<!--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.BasicTemplate
</syntaxhighlight>This is where everything comes together. Your dotnet installation will download the Vintage Story mod template from NuGet (an online package manager for .NET), and install the templates to be used with Visual Studio.
{| class="wikitable mw-collapsible mw-collapsed"
|Looking for the advanced modding template, or want to make a dll-only mod?
|-
|Since ''May 2024'', the template listed above will install only the basic mod template - Which automatically imports all relevant libraries. If you need to select which libraries to import, or you want to make a dll-only mod, you will need to install the advanced templates by entering the following command:<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>
|}


=== Test your template installation === <!--T:14-->
=== 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:VisualStudioVSBasicTemplateSelect.png|center|frameless|558x558px]]




Confirmedusers
637

edits