Modding:Basic Item: Difference between revisions

From Vintage Story Wiki
no edit summary
No edit summary
No edit summary
(21 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__FORCETOC__
__FORCETOC__
This tutorial should introduce you into the basic of adding an item to the game using JSON files. If you want to add a item with functionality you should check out the tutorial for [[Advanced Items]]. There is a full list of all properties which can be defined inside the json file [[Item Json Properties]]. Adding a block to the game is rather similar, so if you have done that already most of the following steps should be known to you.
Please read the tutorial [[Getting Started with Advanced Modding#Domains|Getting Started]] first, if you haven't done it already. This tutorial should introduce you into the basic of adding an item to the game using JSON files. If you want to add a item with functionality you should check out the tutorial for [[Advanced Items]]. There is a full list of all properties which can be defined inside the json file [[Item Json Properties]]. Adding a block to the game is rather similar, so if you have done that already most of the following steps should be familiar to you.


= A Simple Item =
= A Simple Item =


So, the first thing we going to need is an idea. What does this game need. Wait i got it ... the game needs an overpowered wand. Let's call this mod '''MyWandMod'''.
So, the first thing we going to need is an idea. What does this game need? Wait i got it ... the game needs an overpowered wand. Let's call this mod '''MyWandMod'''.


== Workspace ==
== Workspace ==
Line 12: Line 12:
== The Texture ==
== The Texture ==


This is the texture we gonna use [[File:Wand.png]]. In order to use it we need to place it inside the assets folder of the [[Vintagestory folder]]. Therefore the path should look like this: <code>assets/textures/items/tool/wand/wand.png</code>.
This is the texture we gonna use [[File:Wand.png]].


== The Json File ==
In order to use the texture we need to put it at the right place. Therefore create the following folders in your workspace <code>assets/mywandmod/textures/item/</code>. Now rename the texture to <code>wand.png</code> and place it in there.


Now we need to let the game know if its existence. We can accomplish that by creating a json file and placing it inside <code>assets/itemtypes/tool/wand.json</code>.
== The Item File ==
 
To create the actual wand need to create a json file inside <code>assets/mywandmod/itemtypes/</code> in your workspace. In this example we name it <code>wand.json</code>. This file contains the basic properties of your item.


The content of this json file should look as it follows:
The content of this json file should look as it follows:
Line 23: Line 25:
code: "wand",
code: "wand",
creativeinventory: { "general": ["*"] },
creativeinventory: { "general": ["*"] },
texture: { base: "tool/wand/wand" }
texture: { base: "item/wand" }
}
}
</syntaxhighlight>
</syntaxhighlight>


* '''code''': A unique identifier for your item. If you plan a larger mod, it is suggested to prefix your modname to the identifier.
* '''code''': A unique identifier for your item.
* '''creativeinventory''': The creative inventory tabs the itemshould be shown in (currently only 1 tab available)
* '''creativeinventory''': The creative inventory tabs the itemshould be shown in (currently only 1 tab available)
* '''textures''': What textures to apply.
* '''textures''': What textures to apply.


== Testing ==
== Naming the Block ==
 
Now we got almost everything ready, except of a proper name. Create another json file in your workspace <code>assets/mywandmod/lang/en.json</code> and give your item a proper name:
 
<syntaxhighlight lang="json">
{
"item-wand": "Wand"
}
</syntaxhighlight>


Now we got everything ready to run our first test. You should be able to find the added item in the creative inventory.
== Testing/ Distribution ==


[[File:2017-01-30 13-59-27.png|700px]]
There is only one thing left. We need to create a zip file of the assets folder inside your workspace. Either you use an external program (such as WinRAR or 7Zip) or you right-click the <code>assets</code> folder and hit '''Send To''' -> '''Compressed (zipped) folder'''. Eventually you can rename the zip file to <code>MyWandMod.zip</code>. The zip file can be either used for testing purposes or you can send it to other people so they can use it as well.


== Naming the Item ==
Furthermore you need to add a <code>modinfo.json</code> file, check out [[Game_Content_Mod|this tutorial]].


To give the item a proper name, you currently have to manually add a line like this in the file <code>assets/lang/en.json</code>
[https://wiki.vintagestory.at/images/e/ec/MyWandMod.zip MyWandMod.zip]
<syntaxhighlight lang="json">
"item-wand": "Wand",
</syntaxhighlight>


A better way of handling naming and translation will be added once its desired.
To install the mod, navigate to the [[Vintagestory folder]] and place it inside the mods folder.


== Distributing a mod ==


The current modding system does not yet support mod-specific asset folders. The current way of doing it is to create a zip file a user can extract into his game folder that will extract the files into the right folders. Example:
Now we got everything ready to run our first test. You should be able to find the added item in the creative inventory.


[http://wiki.vintagestory.at/images/e/ec/MyWandMod.zip MyWandMod.zip]
[[File:2017-01-30 13-59-27.png|700px]]


A proper mod manager will be added to the game once there is a few serious mods out there (go bug tyron about it ;-) ).
'''Hint''': Use the client command <code>.tfedit</code> if you want to adjust the item position, rotation and scale in Hands, in GUI, when dropped on the ground or in third person mode.


= Advanced Properties =
= Advanced Properties =
Line 141: Line 147:
texturebytype: {
texturebytype: {
"*-shovel": {
"*-shovel": {
base: "tool/wand/wand-shovel",
base: "item/wand-shovel",
},
},
"*-pickaxe": {
"*-pickaxe": {
base: "tool/wand/wand-pickaxe",
base: "item/wand-pickaxe",
},
},
"*-axe": {
"*-axe": {
base: "tool/wand/wand-axe",
base: "item/wand-axe",
},
},
}
}
Line 155: Line 161:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
texture: {
texture: {
base: "tool/wand/wand-{tooltype}",
base: "item/wand-{tooltype}",
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 169: Line 175:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
texture: {
texture: {
base: "tool/wand/wand",
base: "wand",
overlays: [ "tool/wand/wand-overlay-{tooltype}" ],
overlays: [ "item/wand-overlay-{tooltype}" ],
},
},
</syntaxhighlight>
</syntaxhighlight>
Line 180: Line 186:
== Download ==
== Download ==


You can download the mod to test it out yourself: [http://wiki.vintagestory.at/images/e/ec/MyAdvancedWandMod.zip MyAdvancedWandMod.zip]
You can download the mod to test it out yourself: [https://wiki.vintagestory.at/images/e/ec/MyAdvancedWandMod.zip MyAdvancedWandMod.zip]
 
 
 
{{Navbox/modding|Vintage Story}}
Confirmedusers, editor, Administrators
886

edits