Differences

This shows you the differences between two versions of the page.

Link to this comparison view

addfoliagelayers2 [2017/04/04 16:42]
jdmfarms created
addfoliagelayers2 [2017/04/04 16:45]
jdmfarms
Line 1: Line 1:
-====== ​XXX ======  ​+====== ​Add fruits to your map ======  ​
  
 Game Version: ​ FS11 and later\\ Game Version: ​ FS11 and later\\
Line 12: Line 12:
 ===== Intro ===== ===== Intro =====
  
 +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
  
 ===== Prep Work ===== ===== Prep Work =====
  
 +The easy part is adding the textures. Look for the Fruit Type Cotton here [url=http://​www.ls-uk.info/​downloads/​6/​10385.]http://​www.ls-uk.info/​downloads/​6/​10385.[/​url] 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;
 +
 +[url=http://​notepad-plus-plus.org/​]http://​notepad-plus-plus.org/​[/​url]
 +
 +install it
  
 ===== Full Details ===== ===== Full Details =====
  
 +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;
 +
 +[code]<​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;
 +
 +[code]<​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
 +
 +[code]<​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;
 +
 +[code]<​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 [url=http://​www.ls-uk.info/​forum/​index.php?​topic=55177.0.]http://​www.ls-uk.info/​forum/​index.php?​topic=55177.0.[/​url]
 +
 +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 [url=http://​www.rarlabs.com]http://​www.rarlabs.com[/​url]. Copy your map to the mods directory.
 +
 +Just a little revision* If you download fruit mods. You will have to open the fruitmod.zip>​extract to a folder> double click fruitmod.lua>​look for this line;
 +
 +[code]local hudFile = Utils.getFilename("​mods/​Map_Fruits/​cottonHUD.png",​ getUserProfileAppPath());​[/​code]
 +
 +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
 +
 +[code]local hudFile = Utils.getFilename("​mods/​cotton/​cottonHUD.png",​ getUserProfileAppPath());​[/​code]
 +
 +And Some fruitmods that you may download will have a quickplay ​
 +
 +[code]local origLoadStatsFromXML = QuickPlayMenu.loadStatsFromXML;​[/​code]
 +
 +[code]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
 +
 +and 
  
 +Finally, add the cotton.zip to your mods directory.
  
 ---- ----
  
-Original Author:  ​XX | Date:  ​XX+Original Author:  ​Sniper214 ​| Date:  ​November 09, 2011
         ​         ​
 [[modding_tutorials|Modding Index]] | [[map_making|Map Making Tutorials]] [[modding_tutorials|Modding Index]] | [[map_making|Map Making Tutorials]]