Modding:Developing a Content Mod: Difference between revisions

From Vintage Story Wiki
(Publishing, uploading & whats next.)
(Marked this version for translation)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<languages/><translate>
<languages/>
{{GameVersion|1.19.4}}
{{GameVersion|1.19.4}}
__TOC__
__TOC__


Page in progress.
<translate>
<!--T:2-->
Developing a content mod can be simple, but certain files and folders need to be setup correctly. For more information on what can be achieved with a content mod, see [[Modding:Content Mods|Content Mods]].


Developing a content mod can be simple, but certain files and folders need to be setup correctly. For more information on what can be achieved with a content mod, see [[Modding:Content Mods|Content Mods]].
== Selecting an IDE == <!--T:3-->


== Selecting an IDE ==
<!--T:30-->
When creating a content mod, you will likely be using a lot of JSON files. Although JSON is a human-readable format, it can still be beneficial to equip yourself with an '''Integrated Development Environment''' (IDE). Simply put, for the purpose of modifying JSON files, an IDE works as a fancy text editor that helps with formatting.
When creating a content mod, you will likely be using a lot of JSON files. Although JSON is a human-readable format, it can still be beneficial to equip yourself with an '''Integrated Development Environment''' (IDE). Simply put, for the purpose of modifying JSON files, an IDE works as a fancy text editor that helps with formatting.


<!--T:4-->
It is recommended to select from one of the IDEs below.
It is recommended to select from one of the IDEs below.
<!--T:31-->
{| class="wikitable sortable"
{| class="wikitable sortable"
!Name
!Name
Line 38: Line 43:
|}
|}


== Content Mod Setup ==
== Template/Example Mod Setup == <!--T:6-->
As stated above, content mods require a certain file and folder structure to function.


=== Template/Example Setup ===
<!--T:32-->
In progress.
If you want to get into modding and do not wish to manually setup your folders, there are two options. The ''template'' file contains a modinfo, modicon, and folder structure for your mod. The ''example'' file is identical, however contains a number of existing assets which are used within the wiki's tutorials. Both files can be found and downloaded [https://github.com/Nateonus/vsmodexamples/releases/latest from GitHub]. Simply unzip them into your game's mod folder.  


=== Manual Setup ===
== Manual Mod Setup == <!--T:7-->


==== Mod Workspace ====
<!--T:33-->
If you wish to setup your project manually, navigate to your Vintage Story install location, and enter the mods folder. Create a new folder with your mod's name - This will be where all mod-related files will be placed. It is recommended to open this folder in your selected IDE.
If you wish to setup a content mod on your own, or want more understanding of the files, follow the instructions below.  


=== Mod Workspace === <!--T:8-->
<!--T:34-->
To start setting up your mod, navigate to your Vintage Story install location, and enter the mods folder. Create a new folder with your mod's name - This will be where all mod-related files will be placed. It is recommended to open this folder in your selected IDE.
<!--T:9-->
'''Note that creating JSON files may require changing file extensions. If you do not know how to do this, [https://www.indeed.com/career-advice/career-development/how-to-change-file-type follow these instructions].'''
'''Note that creating JSON files may require changing file extensions. If you do not know how to do this, [https://www.indeed.com/career-advice/career-development/how-to-change-file-type follow these instructions].'''


==== ModInfo.json ====
=== ModInfo.json === <!--T:10-->
To register our mod, we have to tell Vintage Story that our mod exists and some details about it. To do this, create a new file called '<nowiki/>''modinfo.json''' inside your mod workspace, either using your IDE or through Windows. Open the file, and paste the following json code:<syntaxhighlight lang="json">
 
<!--T:35-->
For your mod to successfully load, you have to tell Vintage Story that our mod exists, as well as some details about it. To do this, create a new file called '<nowiki/>''modinfo.json''' inside your mod workspace folder, either using your IDE or through Windows. Note that this cannot be created in a subfolder - It must be inside the root mod workspace folder. Open the file, and paste the following json code:
 
<!--T:36-->
<syntaxhighlight lang="json">
{
{
   "type": "content",
   "type": "content",
Line 63: Line 78:
   "version": "1.0.0"
   "version": "1.0.0"
}
}
</syntaxhighlight>This file is a very good example of how a json file is formatted, and you will notice that nearly every asset uses this file format. Json files list a set of "key": "value" entries, allowing you to change those values to fit what is desired. In this case, the following keys represent:
</syntaxhighlight>
 
<!--T:37-->
This file is a very good example of how a json file is formatted, and you will notice that nearly every asset uses this file format. Json files list a set of "key": "value" entries, allowing you to change those values to fit what is desired. In this case, the following keys represent:


* '''"type": "content"''' - This tells Vintage Story that the mod is a content mod, and should load the provided assets. The options here are "theme", "content", or "code", however for this mod type we will use "content".
<!--T:11-->
* '''"type": "content"''' - This tells Vintage Story that the mod is a content mod, and should load the provided assets. The options here are "[[Modding:Theme Pack|theme]]", "[[Modding:Content Mods|content]]", or "code", however for this mod type you will use "content".
* '''"modid": "examplecontentmod"''' - This is your '''unique''' mod ID, which can be any combination of '''lowercase''' letters and numbers.
* '''"modid": "examplecontentmod"''' - This is your '''unique''' mod ID, which can be any combination of '''lowercase''' letters and numbers.
* '''"name": "..."''' - This is your mod's name, and displays how it should be displayed within the game. Note that this is just for display and does not affect the assets you create.
* '''"name": "..."''' - This is your mod's name, and displays how it should be displayed within the game. Note that this is just for display and does not affect the assets you create.
* '''"authors": [ "..." ]''' - This is an ''array'' of mod authors. Due to this entry using square brackets ('''[ ]''')''',''' it tells us that this value can accept multiple values, which are seperated by commas.
* '''"authors": [ "..." ]''' - This is an ''array'' of mod authors. Due to this entry using square brackets ('''[ ]''')''',''' it tells you that this value can accept multiple values, which are seperated by commas.
* '''"description": "..."''' - This is the mod description, which will be shown on the mod manager screen in game.
* '''"description": "..."''' - This is the mod description, which will be shown on the mod manager screen in game.
* '''"version": "1.0.0"''' - This is your mod's version. It follows the format of "major.minor.patch", called [https://semver.org/ semantic versioning].
* '''"version": "1.0.0"''' - This is your mod's version. It follows the format of "major.minor.patch", called [https://semver.org/ semantic versioning].


Also note that our file starts and ends with curly brackets ('''{ })'''. This tells us that this file contains a ''single'' object. If a json file starts with square brackets ('''[ ]'''), this tells us that we can register multiple objects within that single file.
<!--T:12-->
Also note that our file starts and ends with curly brackets ('''{ }'''). This tells us that this file contains a ''single'' object. If a json file starts with square brackets ('''[ ]'''), this tells us that you can include multiple objects within that single file.


You can fill in the values above with your own mod info, or keep them the same. Most tutorials on the wiki will use this modinfo file.
<!--T:13-->
You can fill in the values above with your own mod info, or keep them the same. Most tutorials on the wiki will use this (or a very similar) modinfo file.


<!--T:14-->
This is just a basic modinfo file. For more information, and a more comprehensive list of available properties, visit the [[Modinfo]] page.
This is just a basic modinfo file. For more information, and a more comprehensive list of available properties, visit the [[Modinfo]] page.


==== Modicon.png ====
=== Modicon.png === <!--T:15-->
If desired, an image file called '<nowiki/>''modicon.png''' can be placed or created inside your mod workspace. This will automatically be loaded into Vintage Story, and be displayed next to your mod on the mod manager menu.
 
<!--T:38-->
If desired, an image file called '<nowiki/>''modicon.png''' can be placed or created inside the root folder of your mod workspace. This will automatically be loaded into Vintage Story, and be displayed next to your mod on the mod manager menu.
 
=== Assets Folder === <!--T:16-->


==== Assets Folder ====
<!--T:39-->
To actually create and modify game assets, Vintage Story searches for specific filepaths. Inside your mod workspace, create a folder called '<nowiki/>''assets''<nowiki/>'. This is where we place our different mod ''domains.'' Similar to your mod id, domains must be lowercase. More information on domains can be found in '''Domains''<nowiki/>' section on this page.
To actually create and modify game assets, Vintage Story searches for specific filepaths. Inside your mod workspace, create a folder called '''assets''<nowiki/>'.


Inside the new assets folder, create another new folder with the same name as your mod id. For example, my folder would be called '<nowiki/>''examplecontentmod''', as this is my mod id. This new folder is where your mod assets will be created! If a tutorial refers to your 'mod assets' folder, it is likely referring to this folder.
<!--T:17-->
Inside the new assets folder, create another new folder with the same name as your mod id. For example, my folder would be called '<nowiki/>''examplecontentmod''', as this is my mod id. This new folder is called a ''domain'', and a single mod can be made up of a number of domains. Therefore, domains can actually have any name, but they must also be made from lowercase letters and numbers. This new folder is where your mod assets will be created! If a tutorial refers to your 'mod assets' folder, it is likely referring to this folder.


<!--T:18-->
When your mod assets folder has been created, you are officially ready to start modding! Check out the '<nowiki/>''What's Next''' section to link to tutorials, and come back here when you need a reminder of how to organise your content mod.
When your mod assets folder has been created, you are officially ready to start modding! Check out the '<nowiki/>''What's Next''' section to link to tutorials, and come back here when you need a reminder of how to organise your content mod.


== Mod Domains ==
== Mod Domains == <!--T:19-->
When Vintage Story loads your mod, it looks inside your mod's root assets folder to find subfolders. Each one of these subfolders dictates a mod ''domain.'' A domain works as an identifier to seperate assets from multiple mods, and must be lowercase.


For example, imagine there exists two mods which both add in a new metal called 'Natium', but with slightly different functionality. Mod A adds the metal to work as a beginner-level metal, however Mod B adds the metal as an endgame metal. Without domains, Vintage Story would not be able to isolate these items based on the code alone, so it prefixes the domain to every asset. The code for Natium in Mod A now becomes "''moda:natium''", and the code for Mod B now becomes "''modb:natium''".
<!--T:40-->
Each subfolder inside your mod's root assets folder dictates a mod ''domain.'' A domain works as an identifier to seperate assets from multiple mods, and must be made up of lowercase letters and numbers.


When creating content mods, you will access many different assets from inside your files, and it is important to understand how domains affect this. If you reference '''Asset A''<nowiki/>' in another asset's file, Vintage Story will automatically prefix your domain onto that reference. However, if you wish to reference an asset that exists in another domain, including the base game, you will need to add that prefix yourself.
<!--T:20-->
For example, imagine there exists two mods which both add in a new metal called 'Natium'. Without domains, Vintage Story would not be able to isolate these items based on the code alone, so it prefixes the domain to every asset. The code for Natium in Mod A now becomes "''moda:natium''", and the code for Mod B now becomes "''modb:natium''".


For example, let us assume that '<nowiki/>''Asset A''<nowiki/>' in the '<nowiki/>''examplecontentmod'<nowiki/>'' domain wishes to access the default copper texture, which is located at '''block/metal/ingot/copper'.'' If you put that reference inside ''Asset A,'' Vintage Story will change that to "''examplecontentmod:block/metal/ingot/copper','' which will proceed to not work due to the file not existing in that domain. To counter this, you need to prefix that reference manually with the default game prefix, and place it as "''game:block/metal/ingot/copper''". This can also be used with other mod domains to use assets from other mods.
<!--T:21-->
When creating content mods, you will access many different assets from inside your files, and it is important to understand how domains affect this. If you wish to reference an asset that exists in another domain, including the base game, you will need to prefix the reference with the domain ID. If you are referencing an asset in the same domain, you do not have to add a prefix to your reference.


<!--T:22-->
For example, let us assume that '<nowiki/>''Asset A''<nowiki/>' in the '<nowiki/>''examplecontentmod'<nowiki/>'' domain wishes to access the default copper texture, which is located at '''block/metal/ingot/copper'.'' If you use that asset location inside ''Asset A,'' Vintage Story will change it to "''examplecontentmod:block/metal/ingot/copper','' which will proceed to not work due to the file not existing in that domain. To counter this, you need to prefix the asset location manually with the default game prefix, and place it as "''game:block/metal/ingot/copper''". This can also be used with other mod domains to use assets from other mods.
<!--T:23-->
Note that all base game assets are placed under the '<nowiki/>''game''' domain.
Note that all base game assets are placed under the '<nowiki/>''game''' domain.


== Navigating Assets & Types ==
== Publishing a Content Mod == <!--T:24-->


== Publishing a Content Mod ==
<!--T:41-->
If you want to distribute your mod for others to play, it is a good idea to pack your mod into a zip file. The best way to achieve this is to use the [https://www.7-zip.org/download.html 7zip program], or another zip program of your choice.
If you want to distribute your mod for others to play, it is a good idea to pack your mod into a zip file. Most operating systems include functionality to zip a set of files, but the [https://www.7-zip.org/download.html 7-zip program] is a good alternative to this.


To pack your mod on Windows, select your modinfo, modicon, and assets folder, and right click on one of the files. In the context window, hover over "''7-zip''", and then select "''Add to archive...''". When entering a name for your zip file, most mods follow the format of "''modid-version".'' This allows users of your mod to easily differentiate between the version of mod you are using. Select '<nowiki/>''OK''' and your zip file will be created.
<!--T:25-->
To pack your mod on Windows, select your modinfo, modicon, and assets folder, and right click on one of the files. In the context window, hover over "Send to", and then select "''Compressed (zipped) folder''". When entering a name for your zip file, most mods follow the format of "''modid-version".'' This allows users of your mod to easily differentiate between versions of your created mod.


<!--T:42-->
[https://copyrightservice.co.uk/reg/creating-zip-files This article] gives information on how to zip a set of files on other operating systems.
<!--T:26-->
This file can then be uploaded for people to use on the [https://mods.vintagestory.at/ Vintage Story ModDB].
This file can then be uploaded for people to use on the [https://mods.vintagestory.at/ Vintage Story ModDB].


<!--T:27-->
After each publish, it is recommended to increase your version number in your modinfo file.
After each publish, it is recommended to increase your version number in your modinfo file.


== Updating a Content Mod ==
== Updating a Content Mod to a new Game Version == <!--T:28-->
As the base game is built using the content mod system, it is highly unlikely that your content mod will need modifying for newer versions. When a new major version is released, there may be rare instances where some formatting changes can cause side-effects, however these are very rare and would mainly happen when using more complex functionality.
 
<!--T:43-->
When Vintage Story updates, it is highly unlikely that your content mod will need modifying. When a new major version is released, there may be rare instances where some formatting changes can cause side-effects, however these are very rare and would mainly happen when using more complex functionality.
 
== What's Next? == <!--T:29-->


== What's Next? ==
<!--T:44-->
Now your content mod has been setup, see what's next on the [[Modding:Content Mods#Following the Wiki Tutorials|Content Mod]] page.{{Navbox/modding|Vintage Story}}
Now your content mod has been setup, see what's next on the [[Modding:Content Mods#Following the Wiki Tutorials|Content Mod]] page.
</translate>
</translate>
{{Navbox/contentmodding}}

Latest revision as of 09:49, 7 April 2024

Other languages:
  • English

This page was last verified for Vintage Story version 1.19.4.

Developing a content mod can be simple, but certain files and folders need to be setup correctly. For more information on what can be achieved with a content mod, see Content Mods.

Selecting an IDE

When creating a content mod, you will likely be using a lot of JSON files. Although JSON is a human-readable format, it can still be beneficial to equip yourself with an Integrated Development Environment (IDE). Simply put, for the purpose of modifying JSON files, an IDE works as a fancy text editor that helps with formatting.

It is recommended to select from one of the IDEs below.

Name Free? Works on... Recommended for Code Mods
Visual Studio (Recommended) Yes - Community Edition Windows Yes
Visual Studio Code Yes Windows, macOS, Linux Yes
JetBrains Rider No Windows, macOS, Linux Yes
Notepad++ Yes Windows No

Template/Example Mod Setup

If you want to get into modding and do not wish to manually setup your folders, there are two options. The template file contains a modinfo, modicon, and folder structure for your mod. The example file is identical, however contains a number of existing assets which are used within the wiki's tutorials. Both files can be found and downloaded from GitHub. Simply unzip them into your game's mod folder.

Manual Mod Setup

If you wish to setup a content mod on your own, or want more understanding of the files, follow the instructions below.

Mod Workspace

To start setting up your mod, navigate to your Vintage Story install location, and enter the mods folder. Create a new folder with your mod's name - This will be where all mod-related files will be placed. It is recommended to open this folder in your selected IDE.

Note that creating JSON files may require changing file extensions. If you do not know how to do this, follow these instructions.

ModInfo.json

For your mod to successfully load, you have to tell Vintage Story that our mod exists, as well as some details about it. To do this, create a new file called 'modinfo.json' inside your mod workspace folder, either using your IDE or through Windows. Note that this cannot be created in a subfolder - It must be inside the root mod workspace folder. Open the file, and paste the following json code:

{
  "type": "content",
  "modid": "examplecontentmod",
  "name": "VS Wiki Example Content Mod",
  "authors": [
    "Nat @ Vintage Story Wiki"
  ],
  "description": "An example showcase of content mod additions.",
  "version": "1.0.0"
}

This file is a very good example of how a json file is formatted, and you will notice that nearly every asset uses this file format. Json files list a set of "key": "value" entries, allowing you to change those values to fit what is desired. In this case, the following keys represent:

  • "type": "content" - This tells Vintage Story that the mod is a content mod, and should load the provided assets. The options here are "theme", "content", or "code", however for this mod type you will use "content".
  • "modid": "examplecontentmod" - This is your unique mod ID, which can be any combination of lowercase letters and numbers.
  • "name": "..." - This is your mod's name, and displays how it should be displayed within the game. Note that this is just for display and does not affect the assets you create.
  • "authors": [ "..." ] - This is an array of mod authors. Due to this entry using square brackets ([ ]), it tells you that this value can accept multiple values, which are seperated by commas.
  • "description": "..." - This is the mod description, which will be shown on the mod manager screen in game.
  • "version": "1.0.0" - This is your mod's version. It follows the format of "major.minor.patch", called semantic versioning.

Also note that our file starts and ends with curly brackets ({ }). This tells us that this file contains a single object. If a json file starts with square brackets ([ ]), this tells us that you can include multiple objects within that single file.

You can fill in the values above with your own mod info, or keep them the same. Most tutorials on the wiki will use this (or a very similar) modinfo file.

This is just a basic modinfo file. For more information, and a more comprehensive list of available properties, visit the Modinfo page.

Modicon.png

If desired, an image file called 'modicon.png' can be placed or created inside the root folder of your mod workspace. This will automatically be loaded into Vintage Story, and be displayed next to your mod on the mod manager menu.

Assets Folder

To actually create and modify game assets, Vintage Story searches for specific filepaths. Inside your mod workspace, create a folder called 'assets'.

Inside the new assets folder, create another new folder with the same name as your mod id. For example, my folder would be called 'examplecontentmod', as this is my mod id. This new folder is called a domain, and a single mod can be made up of a number of domains. Therefore, domains can actually have any name, but they must also be made from lowercase letters and numbers. This new folder is where your mod assets will be created! If a tutorial refers to your 'mod assets' folder, it is likely referring to this folder.

When your mod assets folder has been created, you are officially ready to start modding! Check out the 'What's Next' section to link to tutorials, and come back here when you need a reminder of how to organise your content mod.

Mod Domains

Each subfolder inside your mod's root assets folder dictates a mod domain. A domain works as an identifier to seperate assets from multiple mods, and must be made up of lowercase letters and numbers.

For example, imagine there exists two mods which both add in a new metal called 'Natium'. Without domains, Vintage Story would not be able to isolate these items based on the code alone, so it prefixes the domain to every asset. The code for Natium in Mod A now becomes "moda:natium", and the code for Mod B now becomes "modb:natium".

When creating content mods, you will access many different assets from inside your files, and it is important to understand how domains affect this. If you wish to reference an asset that exists in another domain, including the base game, you will need to prefix the reference with the domain ID. If you are referencing an asset in the same domain, you do not have to add a prefix to your reference.

For example, let us assume that 'Asset A' in the 'examplecontentmod' domain wishes to access the default copper texture, which is located at 'block/metal/ingot/copper'. If you use that asset location inside Asset A, Vintage Story will change it to "examplecontentmod:block/metal/ingot/copper', which will proceed to not work due to the file not existing in that domain. To counter this, you need to prefix the asset location manually with the default game prefix, and place it as "game:block/metal/ingot/copper". This can also be used with other mod domains to use assets from other mods.

Note that all base game assets are placed under the 'game' domain.

Publishing a Content Mod

If you want to distribute your mod for others to play, it is a good idea to pack your mod into a zip file. Most operating systems include functionality to zip a set of files, but the 7-zip program is a good alternative to this.

To pack your mod on Windows, select your modinfo, modicon, and assets folder, and right click on one of the files. In the context window, hover over "Send to", and then select "Compressed (zipped) folder". When entering a name for your zip file, most mods follow the format of "modid-version". This allows users of your mod to easily differentiate between versions of your created mod.

This article gives information on how to zip a set of files on other operating systems.

This file can then be uploaded for people to use on the Vintage Story ModDB.

After each publish, it is recommended to increase your version number in your modinfo file.

Updating a Content Mod to a new Game Version

When Vintage Story updates, it is highly unlikely that your content mod will need modifying. When a new major version is released, there may be rare instances where some formatting changes can cause side-effects, however these are very rare and would mainly happen when using more complex functionality.

What's Next?

Now your content mod has been setup, see what's next on the Content Mod page.

Content Modding
Basics Content Mods Developing a Content Mod
Tutorials
Concepts Modding Concepts Variants Domains Patching Remapping World Properties
Uncategorized
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