Add fruits to your map

Game Version: FS11 and later
GE Version: ? and later

Modding Index | Map Making Tutorials

Since I have been seeing/receiving a number of add fruit requests, I decided to write a step by step tutorial on how to add a fruit to your map.

I will use cotton for this little venture. Credits to Conraad for the mod

The easy part is adding the textures. Look for the Fruit Type Cotton here It will come with the necessary images/textures.

Before anything is done heave my advice BACKUP YOUR MAP!! at least 2 different places, I have mine backed up at least 4 times in different drives. You have been warned and I take no responsibility if you muck up your map.

First get Notepad++ highly recommended and all text editing functions will be from notepad++ only. So get it here;

install it

Now, you will need to extract your map to a folder

Place the foliage_cotton_diffuse and foliage_cotton_cut_short into yourmap/textures/foliage

Right click map01.i3d>edit with notepad++ Your map will open in a XML style format and a lot of code, confusing? It don't have to be, if you are patient.

We will need to add the foliage texture files in to the .i3d file.

in the <Fileid> section at bottom, before </Fileid> paste these lines there;

<File fileId="700" filename="textures/foliage/foliage_cotton_cut_short_diffuse.png" relativePath="true"/>

<File fileId=“701” filename=“textures/foliage/foliage_cotton_diffuse.png” relativePath=“true”/>[/code]

The fileid number needs to high enough and different to avoid conflicts

Now go to the end of <Materials> before </Materials> and paste this there;

<Material name="cottonCutShortMaterial" materialId="800" ambientColor="1 1 1" customShaderId="36">

     <Texture fileId=“700”/>      <CustomParameter name=“alphaBlendStartEnd” value=“70 75 0 0”/>    </Material> <Material name=“cottonMaterial” materialId=“801” ambientColor=“1 1 1” customShaderId=“34”>      <Texture fileId=“701”/>      <CustomParameter name=“alphaBlendStartEnd” value=“70 75 0 0”/>    </Material>[/code]

The Texture fileId needs to be the same number as the fileid in the <Files section> which in this case is 700 and 701. Again the materlid needs to be high enough and different to avoid conflicts. I chose 800 and 801 for this example. To find the customshaderID for the map you are adding the fruit to, you will need to find wheatFoliageShader.xml and cutted_wheat_Foliage_shader.xml. Look for these in the <Files> section in this case they are

<File fileId="34" filename="shaders/wheatFoliageShader.xml" relativePath="true"/>

<File fileId=“36” filename=“shaders/cuttedWheatFoliageShader.xml” relativePath=“true”/>[/code]

So put 34 in the customshaderID for cottonMaterial and 36 in the customshaderID for cottonCutShort Note these vary with every map, so always check.

Now press ctrl+f and search for layers you will see below, the foliagesublayers. You will need to go down to just below the drygrass_windrow section or the very last fruit and before </FoliageMultiLayer> and add this;

<FoliageSubLayer name="cotton" densityMapTypeIndex="7" densityMapChannelOffset="4" numDensityMapChannels="3" materialId="801" cellSize="8" viewDistance="75" terrainOffset="0" objectMask="65520" distanceColors="0.537255 0.439216 0.286275;0.184314 0.294118 0.137255;0.184314 0.294118 0.137255;0.729412 0.67451 0.00392157;0.513726 0.356863 0.109804" separateAvailabilityChannel="false" atlasSize="1" plantThreshold="0.5" numBlocksPerUnit="0.8" width="2.25" height="1.6" widthVariance="0" heightVariance="0.5" horizontalPositionVariance="0.1" growthNumStates="5" growthStateTime="2.6e+006" hasGrowthAtlas="true"/>

<FoliageSubLayer name=“cotton_cut_short” densityMapTypeIndex=“8” densityMapChannelOffset=“7” numDensityMapChannels=“1” materialId=“800” cellSize=“8” viewDistance=“75” terrainOffset=“0” objectMask=“65520” distanceColors=“0.537255 0.447059 0.286275” atlasSize=“1” plantThreshold=“0.5” numBlocksPerUnit=“1.2” width=“2.25” height=“0.5” widthVariance=“0” heightVariance=“0.04” horizontalPositionVariance=“0.5”/>[/code]

Notice the materialid is the same as the materialid in the <Materials> section.

Not much else needs to be editied in the foliagesublayer lines, change the densityMapTypeIndex to the next sequential number. Since dryGrass was 6 then cotton would be 7, then next fruit 8 and so on. You can also adjust the numBlocksPerUnit, width, height and growth times.

I would put the growthStateTime to like 15000 to test the cotton sow/growth/harvest function. 15000ms is like 15 seconds for each stage. If all is well you can change the growthStateTime to whatever you like. Go here for common time conversions

After all edits are done click save>exit You will need to Zip up all files using winrar, winzip, 7zip or any other zip capable program, Winrar is most common Copy your map to the mods directory.

Just a little revision* If you download fruit mods. You will have to open the>extract to a folder> double click fruitmod.lua>look for this line;

local hudFile = Utils.getFilename("mods/Map_Fruits/cottonHUD.png", getUserProfileAppPath());

Make sure that it points to the right file. So if you do not have Map_Fruits, change it accordingly. In this case we don't so we need to change it to

local hudFile = Utils.getFilename("mods/cotton/cottonHUD.png", getUserProfileAppPath());

And Some fruitmods that you may download will have a quickplay

local origLoadStatsFromXML = QuickPlayMenu.loadStatsFromXML;
QuickPlayMenu.loadStatsFromXML = function(self, baseXMLName, savegame)

   origLoadStatsFromXML(self, baseXMLName, savegame);  for i = 1, FruitUtil.NUM_FRUITTYPES do        if savegame.stats.farmSiloFruitAmount[i] == nil then            savegame.stats.farmSiloFruitAmount[i] = 5000;        end;        if savegame.stats.fruitPrices[i] == nil then            savegame.stats.fruitPrices[i] = FruitUtil.fruitIndexToDesc[i].pricePerLiter;        end;        if savegame.stats.yesterdaysFruitPrices[i] == nil then            savegame.stats.yesterdaysFruitPrices[i] = FruitUtil.fruitIndexToDesc[i].yesterdaysPrice;        end;    end; end; [/code]

Remove these lines from the fruitmod.lua or the mod will not work, as these lines are for FS09 fruitmods only. Save>exit>Re-Zip


Finally, add the to your mods directory.

Original Author: Sniper214 | Date: November 09, 2011

Modding Index | Map Making Tutorials