Entity Tutorial 1: Creating a Simple Prop: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
We will begin by creating a simple prop that doesn't have any specific functionality. | We will begin by creating a simple prop that doesn't have any specific functionality. | ||
== Creating the Definition == | |||
Entities can be specified by defining them with JSON. Inside the JSON, we set [[Entity Parameters]]. For the simplest case, only two need to be set: the '''name''' of the object, and a '''description''' for it. | |||
Each parameter can either be a 'literal' value, or a 'program' value. A literal value is a hard coded one, as opposed to a program value, which is determined by executing a script. For our first example, only literal values are used, but in the next example will introduce program values. | |||
There is also a special parameter, the '''type''', which signifies to the mod processing system that this is an Entity. | |||
Thus we can create the following JSON definition: | |||
<syntaxhighlight lang="json"> | <syntaxhighlight lang="json"> | ||
Line 17: | Line 24: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Validating == | |||
Before putting it into the game, it's a good idea to run it through a JSON validator like [https://jsonlint.com/ JSONLint] to make sure no typos in JSON syntax have been made. | |||
== Running == | |||
Having been successfully validated, we can now put it into the game. This will require a private build of r22.5 or later. | |||
Find the Debug Monster Control Panel (in future this will be renamed to something more all-encompassing, as it now supports entities as well as monsters). | |||
The shortest path to it is from the main menu: | |||
* Debug Skip | |||
* Debug Box | |||
* Use | |||
* South | |||
* East | |||
* South | |||
* Control Panel | |||
By using the Program button and copying/pasting the above JSON definition into it, a new item is created in the scene with the name and description specified earlier. | |||
It is generally recommended to leave the Debugbutton as set to OFF. |
Revision as of 03:47, 21 December 2017
We will begin by creating a simple prop that doesn't have any specific functionality.
Creating the Definition
Entities can be specified by defining them with JSON. Inside the JSON, we set Entity Parameters. For the simplest case, only two need to be set: the name of the object, and a description for it.
Each parameter can either be a 'literal' value, or a 'program' value. A literal value is a hard coded one, as opposed to a program value, which is determined by executing a script. For our first example, only literal values are used, but in the next example will introduce program values.
There is also a special parameter, the type, which signifies to the mod processing system that this is an Entity.
Thus we can create the following JSON definition:
{
"type": "ENTITY",
"name":
{
"literalString" : "Shiny Gem"
},
"description":
{
"literalString": "A gem that shines brightly in a variety of colors."
}
}
Validating
Before putting it into the game, it's a good idea to run it through a JSON validator like JSONLint to make sure no typos in JSON syntax have been made.
Running
Having been successfully validated, we can now put it into the game. This will require a private build of r22.5 or later.
Find the Debug Monster Control Panel (in future this will be renamed to something more all-encompassing, as it now supports entities as well as monsters).
The shortest path to it is from the main menu:
- Debug Skip
- Debug Box
- Use
- South
- East
- South
- Control Panel
By using the Program button and copying/pasting the above JSON definition into it, a new item is created in the scene with the name and description specified earlier.
It is generally recommended to leave the Debugbutton as set to OFF.