Make a vegetable mod ?

Post your mods and custom content here

Make a vegetable mod ?

Postby Dryade » Sat Sep 20, 2014 10:50 am

Hello,

I don't know anything in coding but i would like to create my own mod. Not something elaborate but little additions giving more content and fun.
The hardest part for me is to know the list of things to do and where to put it. I think that if i don't try to make "new" functions, but just doing the same thing that the game still could do, it essentially a matter of values. So something i could do myself with help !

I just want to add some vegetables and recipe. For example, add a pumpkin. Since there are other vegetables and recipe, i could probably use the code to make my pumpkin mod, no ?

So, i got some graphism (not really good but enough since it is only for me and a try). Here : link. (harvestable pumpkin, growing pumpkin, harvested pumpkin, pumpkin soup)

I need help to know what to do now ! I think i must

- create the "plant" itself, when it grow, how time it take, associate the graphism of the growing and the harvestable pumpkin ?
- create the "item" pumpkin, harvested, define if it is raw or prepared, something else ? link it to the harvested pumpkin image too.
- create the "item" recipe soup pumpkin, the value of the food, the image too.
- add these thing in the production menu ? For auto-queue and so ?
- make the wild pumpkin plant appears on new world gen
- is food caravan will bring them or must i add them ?
- do i forget something ?

What file must i edit to add all of this ?

Is someone could make me a little "step by step" ? Am i underestimate the difficulty of the modding ? Because i think that if i can create a pumpkin plant and all, i could make any plant i want like tomatos or salads and so on.

Thanks for the answers !
Dryade
 
Posts: 7
Joined: Wed Aug 20, 2014 3:24 pm

Re: Make a vegetable mod ?

Postby Haggy » Sun Sep 21, 2014 10:39 am

I could create you the mod, but I can not enough english to explain you all this.

You have the "c1" change files in the subfolder, strictly speaking, the "gen_items.xml" to grow pumpkins as wild plants.
Then you'd have the actions.xml, menu.xml, menu_production.xml, menu_right.xml, items.xml, graphic.ini also add everything it belonged to.

To explain the whole thing is not that easy ... at least for me.

The caravan would adapt automatically when you make the pumpkins in the "items.xml" correctly.
My English is bad. Sorry, but this will not Change.

Schreib einfach in deutsch zurück ;)

Haggys Mod Comp.
User avatar
Haggy
 
Posts: 528
Joined: Sun Apr 21, 2013 3:34 am

Re: Make a vegetable mod ?

Postby LittleMikey » Sun Sep 21, 2014 10:45 am

I've started writing a long post explaining step by step how you'd go about creating this mod, since I think it'll be useful as a guide to anyone else, however it's getting late here and I'm too tired to continue, so I've saved it as a draft and I'll finish it tomorrow. For now the best advice I can offer is to look in the items.xml (located in your Towns/data directory) folder and look for the Banana item and try and follow how it works. Hopefully when I post my guide it will be a bit clearer!
User avatar
LittleMikey
 
Posts: 986
Joined: Sat Nov 10, 2012 10:32 am
Location: Perth, Australia

Re: Make a vegetable mod ?

Postby LittleMikey » Tue Sep 23, 2014 11:38 pm

Sorry this has taken so long, I managed to get distracted by other things. Here's the first part of what I've written. I'll finish the rest when I can!




Dryade wrote:Hello,

I don't know anything in coding but i would like to create my own mod. Not something elaborate but little additions giving more content and fun.
The hardest part for me is to know the list of things to do and where to put it. I think that if i don't try to make "new" functions, but just doing the same thing that the game still could do, it essentially a matter of values. So something i could do myself with help !

I just want to add some vegetables and recipe. For example, add a pumpkin. Since there are other vegetables and recipe, i could probably use the code to make my pumpkin mod, no ?

So, i got some graphism (not really good but enough since it is only for me and a try). Here : link. (harvestable pumpkin, growing pumpkin, harvested pumpkin, pumpkin soup)

I need help to know what to do now ! I think i must

- create the "plant" itself, when it grow, how time it take, associate the graphism of the growing and the harvestable pumpkin ?
- create the "item" pumpkin, harvested, define if it is raw or prepared, something else ? link it to the harvested pumpkin image too.
- create the "item" recipe soup pumpkin, the value of the food, the image too.
- add these thing in the production menu ? For auto-queue and so ?
- make the wild pumpkin plant appears on new world gen
- is food caravan will bring them or must i add them ?
- do i forget something ?

What file must i edit to add all of this ?

Is someone could make me a little "step by step" ? Am i underestimate the difficulty of the modding ? Because i think that if i can create a pumpkin plant and all, i could make any plant i want like tomatos or salads and so on.

Thanks for the answers !


Okay, the good news it that what you want to do is relatively easy. Most of the work you'll be doing will be creating items for all the various stages of your pumpkin, and only adding one or two lines to other files. I highly recommend getting a text editor like notepad++ (http://notepad-plus-plus.org/) because it makes viewing code a lot easier, by colouring in different parts so you can easily see what you are editing.

If anyone else can improve on my descriptions, feel free to contribute! I'm quite tired as I'm writing this so I'll likely make mistakes!

Here are the files you will need to edit:
graphics.ini
actions.xml
items.xml
menu_right.xml
menu_production.xml (to set up auto-harvesting)
caravans.xml (To add them to the food caravan/let you sell them to the food caravan)
gen_items.xml (Adding them to world gen is slightly more complicated. You'll have to edit the gen_items.xml file in each world you want them to spawn, for instance Normal, Mixed, Jungle etc. I'll explain this later.)

So let's start with the very basics. Go to your user folder (C:/Users/*YOUR NAME* on windows 7) and find the folder called .towns. You may need to turn on hidden folders to see this, I'm not sure. Then open the mods directory, and create a new folder in there with the name of your mod. You can call it whatever you like. In this folder create a new folder called data, so your directory will look like: .towns/mods/*YOUR MOD*/data.

In the data folder, create a new file called items.xml We'll start with the items because they are what ties everything together. If you don't know how to create an .xml file you can go to your main Towns directory and look for the items.xml file in the data folder there. If you're going to do that you may as well copy the other files I mentioned above, but make sure you delete everything in them.

I'm not sure how new you would be to programming, so I'll start with the extreme basics. Each xml file is made up of individual components, and each component can have multiple attributes. In order to start off with in your .xml file you need to specify that you are creating an item. So add the following lines:

Code: Select all
<items>

</items>


The <items> tag means that everything following will be an item, and the </items> tag means that you have finished. As we work we will always be working with pairs of tags, the starting one being <WORD> and the closing one being </WORD>. Make sure you always have a closing tag! Otherwise the game won't realise you have stopped defining whatever it is you're defining!

So now we have told the game that we are defining items, we'll need to actually create an item. In between the <items> and the </items> tag create the following:

Code: Select all
<items>
          <pumpkin>

          </pumpkin>
</items>


Now you see that we're starting to define a Pumpkin as an item. Usually it's best programming etiquette to have all variable names as lowercase, sometimes the program can crash if you have uppercase in one place and lowercase in another. So consistency is key. Also you'll notice that I indented the pumpkin item. This is also really useful etiquette! When you have multiple layers of tags it will be much easier to make sure you are not making mistakes if you can clearly visualise which layer of an item you're working on. Some tags which are made up of multiple words have capital letters on the start of each subsequent word, just to make them read easier, but they always start with a lowercase. For example, <canBeEaten>.

Now, let's give our Pumpkin some attributes. I'm going to copy from the Banana for easiness:

Code: Select all
<items>
   <pumpkin>
      <name>Pumpkin</name>
      <type>prepfood</type>
      <canBeEaten>true</canBeEaten>

      <foodValue>3</foodValue>
      <foodFillPCT>20</foodFillPCT>
      <foodEatTime>16</foodEatTime>
      <foodEffects>fruithappy</foodEffects>
      <value>35</value>
   </pumpkin>
</items>


Now let's go through these attributes:
  • <name> is what the item is called in game.
  • <type> is how the item gets sorted into barrels. prepfood is for prepared food, but fruits also go in there because they can be eaten right away.
  • <canBeEaten> is self explanatory. It simply means that your villagers will be allowed to eat this.
  • <foodValue> is a number given to tell villagers how "important" a piece of food is. Townies will always try and eat a food item with a higher value first. Cooked meals usually have a value of 1, being the most important, and raw meat has a value of 5, so townies will only try and eat it if there is nothing else available.
  • <foodFillPCT> PCT is short for Percent, so this is how much hunger your food will remove from the villagers. Fruit doesn't provide nearly as much nutrition as a full cooked meal, so it has a low effectiveness and needs to be consumed more frequently.
  • <foodEatTime> Food eat time is the amount of time, in "turns" your townies will take to eat the food. Each Turn is roughly 1/6 of a second on normal speed from memory. So your pumpkin will take just under three second to eat.
  • <foodEffects> is the Effect or "Mood" that your townie will get from eating this food. Different foods make your Townies happy. You get the most happiness having a variety of food types available. Because I'm using the Towns++ mod, my effects might be different from what's in vanilla, so check your effects.xml if you want a list of effects your food can give (do a search for "happy". They are all listed as meathappy, fruithappy, etc.)
  • <value> is the default price this item will sell to a Caravan. Normally it will cost 2x this value to buy from a Caravan, from memory, but I could be wrong.



Part 2 coming soon!
User avatar
LittleMikey
 
Posts: 986
Joined: Sat Nov 10, 2012 10:32 am
Location: Perth, Australia

Re: Make a vegetable mod ?

Postby Dryade » Wed Sep 24, 2014 4:28 am

Thanks !

I am very grateful for your help. I will read all of this carefully and try myself :)
Dryade
 
Posts: 7
Joined: Wed Aug 20, 2014 3:24 pm

Re: Make a vegetable mod ?

Postby Ayan Prince » Sat Mar 14, 2015 6:05 am

So let's start with the very basics. Go to your user folder (C:/Users/*YOUR NAME* on windows 7) and find the folder called .towns. You may need to turn on hidden folders to see this, I'm not sure. Then open the mods directory, and create a new folder in there with the name of your mod. You can call it whatever you like. In this folder create a new folder called data, so your directory will look like: .towns/mods/*YOUR MOD*/data.
Get Braindumps demos for Testking practice asvab test Our high quality itil prepares you well before appearing in the final Testking teas v study guide and Florida Southern College exams
Ayan Prince
 
Posts: 1
Joined: Sat Mar 14, 2015 6:04 am

Re: Make a vegetable mod ?

Postby tavernhero » Mon Apr 13, 2015 2:43 am

Ayan Prince wrote:So let's start with the very basics. Go to your user folder (C:/Users/*YOUR NAME* on windows 7) and find the folder called .towns. You may need to turn on hidden folders to see this, I'm not sure. Then open the mods directory, and create a new folder in there with the name of your mod. You can call it whatever you like. In this folder create a new folder called data, so your directory will look like: .towns/mods/*YOUR MOD*/data.


Thanks! I'm gonna give it a try.
I'm a sucker for sim games and other strategy pc games.
tavernhero
 
Posts: 6
Joined: Mon Apr 13, 2015 2:40 am

Re: Make a vegetable mod ?

Postby YetiChow » Tue Apr 14, 2015 5:19 am

tavernhero wrote:
Ayan Prince wrote:So let's start with the very basics. Go to your user folder (C:/Users/*YOUR NAME* on windows 7) and find the folder called .towns. You may need to turn on hidden folders to see this, I'm not sure. Then open the mods directory, and create a new folder in there with the name of your mod. You can call it whatever you like. In this folder create a new folder called data, so your directory will look like: .towns/mods/*YOUR MOD*/data.


Thanks! I'm gonna give it a try.


If you'd like any help or advice with modding, please don't hesitate to ask questions... with the spambot swarm around lately, there hasn't been much point replying to most of the "questions" (read: thinly veiled sales links); but you'll still find plenty of help if you ask for it :)

Also, if you're playing through Steam, the folder directory will be slightly different. Instead of in your User folder, you'll find it under C:/Progam Files/Steam/SteamApps/Common/towns

Make sure to take a backup before you start playing around with the files, and it may be useful to keep a whole second copy on your desktop to test with - when you're happy with how the mod runs you can put a copy of it in the Steam folder; but opening it up each time if you hit some bugs (and trust me, it will happen eventually... all part of the modding process ;)) can be a bit of a pain.
What's that you're eating? A nice, juicy apple? You weren't supposed to eat that you fool, you were supposed to make it into a pie! - last words recorded words of Francis D'Avre before he went looking for snowcherries, but found a hungry Yeti instead.
User avatar
YetiChow
 
Posts: 3149
Joined: Wed Apr 25, 2012 9:26 am
Location: Cramped between a Yeti's small intestine and its stomach... trying not to dissolve!


Return to Modding

Who is online

Users browsing this forum: No registered users and 2 guests

cron