HowToAddGrowers: Difference between revisions
Content deleted Content added
imported>Teiv |
imported>Kymara update to include other types of grower and some examples |
||
| (8 intermediate revisions by 2 users not shown) | |||
Line 1:
= Types of Grower =
The type of grower we are using for this example is called a 'passive' grower. An coconut grows at a spot, and it looks like an coconut has fallen to ground. The grower image on the ground is the same as the image of the item in your bag and to get it to bag you drag and drop. Or you can eat it directly from ground. Other examples of passive entities which just grow from ground are wood, iron ore, spinach, mushroom and toadstools. These times use ''PassiveEntityRespawnPoint''.
But there are other types of grower. For example think of the carrots growing in the grain field in semos plains. There, the grower image is a planted carrot. What you see in bag is a whole carrot. To get it from ground to bag you must right click and Pick it, or double click it to get into bag. These types use ''VegetableGrower''.
Even more advanced is the grain itself. This has several different images as it grows from just planted to ripe. You can only pick grain if you have a scythe. These types use ''GrainField''.
= Passive grower example - the coconut =
<pre>▼
The passive grower is the simplest example which is why we start with coconut.
== Create item ==
First step is to add the coconut to data/conf/items/food.xml
</pre>▼
This is all explained in the [[HowToAddItemsStendhal]] tutorial.
<pre>▼
</pre>▼
How to add the picture for an item is also descriped in [[HowToAddItemsStendhal]].
==
To be able to add the
This picture you have to put in tiled/tileset/logic/item in your source dirctory. After put it in there, you are able to put the image on your map, where the apple should spawn. But at this moment stendhal would not compile. One more step to let it spawn.▼
▲
= Edit PassiveEntityRespawnPointFactory.java =▼
You have to open src/games/stendhal/server/entity/mapstuff/spawner/PassiveEntityRespawnPointFactory.java to add the apple finally to game.<br>▼
▲== Edit PassiveEntityRespawnPointFactory.java ==
▲You have to open ''src/games/stendhal/server/entity/mapstuff/spawner/PassiveEntityRespawnPointFactory.java'' to add the
If you add apple to fruits.png in tileset you have to add apple to:
<pre>
clazz.contains("fruits")
</pre>
When you add a new kind of grower you have to add a new
<pre>
case 0:
passiveEntityrespawnPoint = new PassiveEntityRespawnPoint("
break;
</pre>
The number after
After this all is done and you can add the item to your map.
= Vegetable Grower example - a carrot =
To add a vegetable grower which should have a certain image when it is not ripe, and another image when it is ripe, and another image for the item in bag, we look at the carrot example.
If you like to add an other grower you just have to do the steps ahead. And have a look at ''src/games/stendhal/server/entity/mapstuff/spawner/PassiveEntityRespawnPointFactory.java'', the most parts will be self-explanatory.▼
== Create item ==
as above
== Create image for map editor ==
as above
== Edit PassiveEntityRespawnPointFactory.java ==
▲
▲<pre>
clazz.contains("vegetable")
▲</pre>
(say)
then the next part you make sure you're saying you use a VegetableGrower, for the item e.g. :
▲<pre>
case 1:
passiveEntityrespawnPoint = new VegetableGrower("carrot");
break;
▲</pre>
The case '1' is because it is the number 1 picture in the vegetable.png when we start counting from 0.
==Create grower images==
Now we need a picture of the carrot growing, it should be 32x64 with the topmost tile being an image of the unripe seed. We usually make this a blank tile, in fact. The ripe planted carrot is in the bottom most tile. The image must be saved in ''data/sprites/items/grower/'' with the name ''item''_grower.png. For example carrot_grower.png. If you got the name exactly right, that image is automatically used for the growing carrot.
= More complicated examples =
... such as grain field are beyond the scope of this tutorial. However all you need to know should be within the files in ''src/games/stendhal/server/entity/mapstuff/spawner'', which themselves have comments to explain what is happening. Good luck!
| |||