Modding:Creating A Code Mod: Difference between revisions

From Vintage Story Wiki
mNo edit summary
mNo edit summary
Line 8: Line 8:


'''This tutorial is suitable for modders using Visual Studio. If you have chose to use a different IDE, please refer to the older [[Modding:Setting up your Development Environment|Setting up your Development Environment]] tutorial.'''
'''This tutorial is suitable for modders using Visual Studio. If you have chose to use a different IDE, please refer to the older [[Modding:Setting up your Development Environment|Setting up your Development Environment]] tutorial.'''
=== Updating the Templates ===
Before creating your mod, it is important to check for any updates to the Vintage Story template. Open Windows PowerShell or the command prompt, and enter the following command:<syntaxhighlight lang="powershell">
dotnet new update
</syntaxhighlight>This will check for updates for all templates, and install them if needed.


=== Recommended Knowledge ===
=== Recommended Knowledge ===
Line 18: Line 23:
To create a new code mod, launch Visual Studio, and select 'Create a new project'. In the create menu, select Vintage Story from the dropdown furthest to the right. This will filter the list of templates, to only show ones with the "Vintage Story" project type.
To create a new code mod, launch Visual Studio, and select 'Create a new project'. In the create menu, select Vintage Story from the dropdown furthest to the right. This will filter the list of templates, to only show ones with the "Vintage Story" project type.
[[File:VisualStudioVSBasicTemplateSelect.png|center|frameless|558x558px]]
[[File:VisualStudioVSBasicTemplateSelect.png|center|frameless|558x558px]]
Select the 'Vintage Story Basic Mod Template'. This will load a new menu asking for a project name, location, and solution name.  
Select the 'Vintage Story Basic Mod Template' and click next. This will load a new menu asking for a project name, location, and solution name.  


Your project name should follow these requirements:
Your project name should follow these requirements:
Line 24: Line 29:
* Not contain any spaces or punctuation.
* Not contain any spaces or punctuation.
* Be formatted in ''[https://www.theserverside.com/definition/Pascal-case PascalCase].''
* Be formatted in ''[https://www.theserverside.com/definition/Pascal-case PascalCase].''
* Not be abbreviated (''MyFirstMod'' instead of ''MFM'').
* Not be abbreviated (Use ''MyFirstMod'' instead of ''MFM'').


Your project name will also determine your Mod ID, however this ''can'' be altered later. Your mod id will be converted to all lower case.
Your project name will also determine your Mod ID, however this ''can'' be altered later.


</translate>
</translate>
{{Navbox/codemodding}}
{{Navbox/codemodding}}

Revision as of 10:42, 23 May 2024

This page was last verified for Vintage Story version 1.19.8.


Prerequisites

Before creating a code mod, you need to have completed the Preparing For Code Mods tutorial. This will show you how to setup your development environment, install dotnet, and install the modding template. If you have done that, you can carry on with this tutorial.

This tutorial is suitable for modders using Visual Studio. If you have chose to use a different IDE, please refer to the older Setting up your Development Environment tutorial.

Updating the Templates

Before creating your mod, it is important to check for any updates to the Vintage Story template. Open Windows PowerShell or the command prompt, and enter the following command:

dotnet new update

This will check for updates for all templates, and install them if needed.

Recommended Knowledge

Before continuing, it is highly advisable to have some knowledge of Visual Studio and the C# programming language. These topics are out of the scope of this tutorial, however if you can understand the following tutorials, you should be okay:

Creating a New Mod

To create a new code mod, launch Visual Studio, and select 'Create a new project'. In the create menu, select Vintage Story from the dropdown furthest to the right. This will filter the list of templates, to only show ones with the "Vintage Story" project type.

VisualStudioVSBasicTemplateSelect.png

Select the 'Vintage Story Basic Mod Template' and click next. This will load a new menu asking for a project name, location, and solution name.

Your project name should follow these requirements:

  • Not contain any spaces or punctuation.
  • Be formatted in PascalCase.
  • Not be abbreviated (Use MyFirstMod instead of MFM).

Your project name will also determine your Mod ID, however this can be altered later.


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