Modding:Простой предмет

From Vintage Story Wiki
Revision as of 09:26, 22 July 2020 by NlgEndlessplay (talk | contribs) (Created page with "== Простой предмет == Первое, что нам нужно, это идея. Что нужно этой игре? Подождите! Я понял ... игр...")

Во-первых, если вы этого еще не сделали, прочитайте руководство ро Системе активов. Это руководство должно познакомить вас с основами использования файлов JSON для добавления предметов в игру. Если вы хотите добавить предмет с функциональностью, вам следует обратиться к учебнику для Продвинутых предметов. На этой странице содержится полный список всех свойств, которые можно определить в файле json - Свойства предметов. Добавление блока в игру аналогично добавлению предмета, поэтому, если вы уже научились это делать, большинство следующих шагов должны быть знакомы.

Простой предмет

Первое, что нам нужно, это идея. Что нужно этой игре? Подождите! Я понял ... игре нужна крутая палочка. Давайте назовем этот мод BasicItem, потому что это руководство по созданию предметов, и мы делаем палочку.

Workspace

First create a folder to put the mod files in, which will become your workspace where we will create the mod itself. We will have to add several folders inside the main folder to keep our files organized. The Vintage Story mod loader requires some files to be placed in specific folders so the loader can find what it needs to load. For this mod, everything will go in our namespaced assets folder. For us, this folder is assets/basicwand/. Note: the namespace does not need to be the same as the name of the mod.

All mods that add content must be in the <assets folder> and their own namespace directory. The namespace, for us is basicwand. This convention prevents multiple mods that use the same item code from causing issues. For example, if you enable extended debug info with the command .edi, you may notice that all the items in the game are prefixed with game:, which is the namespace for all the vanilla content.

After getting our workspace ready, we can move on to actually making the wand.

Adding a Texture

Let's start with the texture we will use: Wand.png

In order to use the texture, we need to put it in the right place (so the mod loader can find it). To do this we will create the folder textures/item/. Remember, this is in our namespaced folder so the full path is assets/basicwand/textures/item/.

Creating the Item File

To create the actual wand item, we need to create a JSON file inside the itemtypes/ folder. In this example we name it wand.json. This file contains the basic properties of our item.

The most basic item requires two things:

  • code: A unique identifier for the item.
  • texture: What textures to apply to the item.

We also need to include this property to allow us access to our item in the creative inventory:

  • creativeinventory: defines the creative inventory tabs where the item should be shown

For now, our values for each property are simple:

  • code: wand
  • texture: item/wand (Note that the specified path does not include texture in the path.)
  • creativeinventory: general

Finally the values in the actual JSON look like this:

{
  code: "wand",
  creativeinventory: {
    "general": ["*"]
  },
  texture: {
    base: "item/wand"
  }
}

You might have noticed that the creativeinventory and texture properties aren't as simple as the code values. The reason for the differences in texture and creativeinventory isn't something we'll cover in this tutorial, but is discussed in advanced tutorials.

Naming the Item

Now we've got almost everything ready, except for a proper name. To do this we create another JSON file: lang/en.json. The game uses this file to look up the name of the item. The language files have a very simple syntax: "item-code": "Item Name".

For our wand, this means our file should look something like this:

{
  "item-wand": "Wand"
}

Conclusion

Together, the item and language files are technically enough to be a complete mod. But they don't add the cool wand I said we would make at the beginning of this tutorial. In order to add more properties, we have to head over to the Modding:Advanced Item tutorial where I explain how we can do way cooler things with items than just create a measly stick.

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 Пакет тем
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 ItemEntityEntity BehaviorsBlockBlock BehaviorsBlock ClassesBlock EntitiesBlock Entity BehaviorsCollectible 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