Modding:Content Tutorial Simple Item: Difference between revisions

From Vintage Story Wiki
Finalizing item type tutorial
(Unfinished but getting there...)
(Finalizing item type tutorial)
Line 80: Line 80:
[[File:SimpleItemTutorialWandNoPositioning.png|frameless]]
[[File:SimpleItemTutorialWandNoPositioning.png|frameless]]


Now, that certainly looks closer to what we wanted.
Now, that certainly looks closer to what we wanted, but the position of the item is wrong.
 
== Positioning the Item ==
Your item is nearly complete, however the 3d object does not have the correct transformation. A transformation, in 3d graphics, refers to an object's position, rotation, and scale.
 
=== Using the Transform Editor ===
To allow modders to easily position items and blocks correctly, Vintage Story utilises a transform editor that can be accessed in game. When in game, hold the item you wish to position and use the command ''<nowiki/>'.tfedit' to open the transform editor.''
 
The transform editor allows you to select where the object is rendered, and adjust its transformation directly. The best part about this is the generated json code at the bottom of this editor, which you can copy and paste straight into your item file.
 
It is recommend to learn how to use the transform editor, since it is an invaluable tool for transforming items and blocks.
 
Changes made within the transform editor do not modify any files, and will therefore not save. For each item you create, it is recommended to set positions for ground, main hand, and gui. These use the properties ''groundTransform'', ''tpHandTransform,'' and ''guiTransform'' respectively.
 
To transform your wand correctly, add the following properties. Don't forget to add a comma after the final curly bracket on the previous shape element.<syntaxhighlight lang="json">
"guiTransform": {
    "translation": {
      "x": 0,
      "y": 0,
      "z": 0
    },
    "rotation": {
      "x": -89,
      "y": 41,
      "z": 33
    },
    "origin": {
      "x": 0.48,
      "y": 0,
      "z": 0.38
    },
    "scale": 1.78
  },
"groundTransform": {
    "translation": {
      "x": 0,
      "y": 0,
      "z": 0
    },
    "rotation": {
      "x": 0,
      "y": 0,
      "z": 0
    },
    "origin": {
      "x": 0.5,
      "y": 0,
      "z": 0.5
    },
    "scale": 3.4
  },
"tpHandTransform": {
    "translation": {
      "x": -0.45,
      "y": 0.03,
      "z": -0.66
    },
    "rotation": {
      "x": 90,
      "y": 0,
      "z": 0
    },
    "origin": {
      "x": 0.5,
      "y": 0,
      "z": 0.5
    },
    "scale": 0.8
  }
</syntaxhighlight>To see if the changes are correct, you can simply reload the world. Hopefully, if everything worked correctly, you should find that your wand now fits better in the player's hand, as well as appearing in the gui more appropriately.
 
[[File:SimpleItemContentTutorialItemPositionButNoName.png|frameless]]
 
There is one final change before the item is complete.
 
== Renaming the Item ==
Currently, every instance of the item is called ''<nowiki/>'simpleitem:item-simplewand'.'' To fix this, you need to add an entry to the lang file. Open up the provided ''en.json'' language file, found in ''assets/simpleitem/lang.''
 
This sample lang file contains two premade translations, to show you how the file works. <syntaxhighlight lang="json">
{
  "template-lang-1": "Template Lang 1",
  "template-lang-2": "Template Lang 2"
}
</syntaxhighlight>On the left is the translation key, and on the right is the translated string. Add a new entry to this file by adding a comma after the second sample translation, and a new line. In this case, the translation key is '<nowiki/>''item-simplewand'<nowiki/>''. Note that this is how the game is currently displaying the name, minus the mod domain prefix. The translated string for this should be '<nowiki/>''Simple Wand'<nowiki/>''.<syntaxhighlight lang="json">
{
  "template-lang-1": "Template Lang 1",
  "template-lang-2": "Template Lang 2",
  "item-simplewand": "Simple Wand"
}
</syntaxhighlight>Both sample translations are not used, and can be deleted if you want to.
 
To speed up testing, if you still have Vintage Story open, you can use the command '<nowiki/>''.reload lang''' to reload all lang files. Hovering over your item should show that our lang file has taken effect.
 
[[File:SimpleItemTutorialFinalImageWorking.png|frameless]]
 
== Conclusion ==
Congratulations, you have now created your first item! This tutorial should have given you some understanding of items, textures, shapes and language files, as well as the basics of modding for Vintage Story!
 
=== Next Steps... ===
If you want to test your knowledge, consider doing the tasks under the ''Going Further'' section below.
 
When you're ready, try out the next tutorial: [[Modding:Content Tutorial Simple Block|Simple Block]]. This will show you how to create a new block with a texture.


== Going Further ==
== Going Further ==
Line 112: Line 213:
!Create a copy of the texture with a different name and color, and a duplicate itemtype file. In the new itemtype file, change the item code and change the texture property to your new texture path. Don't forget to add new lang translation entries!  
!Create a copy of the texture with a different name and color, and a duplicate itemtype file. In the new itemtype file, change the item code and change the texture property to your new texture path. Don't forget to add new lang translation entries!  
|}
|}
== Conclusion ==
Congratulations, you have now '''(created your first item...)'''! This tutorial should have given you some understanding of '''(blah blah blah)'''.
=== Next Steps... ===
Try out the next tutorial, '''(link).''' This will show you how to create a '''(...)'''!


{{Navbox/contentmodding}}
{{Navbox/contentmodding}}
</translate>
</translate>
Confirmedusers
637

edits