Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/28/2023 in all areas

  1. Create Field Dimensions and Farmlands Tutorial This tutorial will endeavour to show you how to create field dimensions, paint the farmland area (InfoLayer_farmlands.grle) and automatically add the relevant farmland entries in the farmland.xml together with painting your chosen Ground Type (i.e Plowed,Cultivated etc) and painting foliage at a chosen growing state on the chosen field using custom scripts. For clarity the abbreviation TG will be used to denote a Transform Group throughout this tutorial. I would like to thank Modelleicher for allowing me to use and giving permission to slightly modify the following scripts in this tutorial in order to add some extra functions. Create Field Dimension Panel Creates field dimensions from markers Paint_Farmland_Field_ID_Panel Paints the InfoLayer farmlands.grle and adds relevant data to the farmlands.xml. Paint Field Ground Foliage Panel Paints the chosen Ground Type (i.e.Plowed,Cultivated etc) and Foliage at a chosen state (i.e. wheat, harvest ready). All scripts are available in the Field Dimensions and Farmlands zip file available at the end of the tutorial. Also have a look at the following youTube videos by Modelleicher on the creation of the original scripts and for a master class on script creation. https://www.youtube.com/watch?v=jLL7x064mJc --Field Dimensions https://www.youtube.com/watch?v=QhCOBkOxjPE –Paint Farmlands https://www.youtube.com/watch?v=dxnZI8C02NY --Farmlands.xml Create Field Dimensions, Create Farmlands and Paint Ground and Foliage on the field The three scripts used for this are the Create Field Dimension Panel, Create Farmlands Panel and the Paint Field Ground Foliage Panel. The Paint Field Ground Foliage Panel script now automatically reads the Foliage Type, Ground Type, Ground Angle, Spray Type associated with your map from the map.i3d and displays it in a dropdown selection. However the Foliage State for each Foliage Type still requires a number value (position in the Layer State dropdown in GE) To assist with this the script now reads all the Foliage States of each Foliage Type directly from the maps foliage folder xml’s and prints result to the console log and to a foliage_States.txt file in the same folder as the map.i3d for easy reference, the image below shows the extracts from console log print out and the foliage_States.txt file . The foliage states listed here are from a test map based on the US map so yours may differ depending on your map set up. Open your map in Giants Editor and Select –Scripts, select the Field Dimensions and Farmlands folder to open it and then select the Create Field Dimension Panel script a popup Panel will appear on your screen. A new transform Group will automatically have been created in the Scenegraph called Field_Creation_Transform consisting of the following TG groups newFieldMarkers – this TG will be the the reference point for the fieldMapIndicator and also contains the Markers transform where the markers are placed. fieldsNew -- containing a fields transform although this will have the FieldUtil.onCreate attribute set by the script I suggest deleting the attributes and reassigning them by Add New Attribute --Type --scriptcallback -- onCreate -- Add and in the new onCreate box enter FieldUtil.onCreate as some times GE doesn't recognise some script set User Attributes. This only applies to the field TG in the fieldsNew TG. The relevant entries created in this fields TG must be copy/pasted in to the gameplay –fields TG replacing originals before using in game farmlandDimensions -- containing a fields TG with the FieldUtil.onCreate attribute set. This will be used in the creation of the farmlandsDimensions Create a primitive (Create –Primitives, I will be using a cone throughout this tutorial.) and cut/paste into the newFieldMarkers transform (this will be the position of your fieldMapIndicator in the new fields TG). Copy/paste a cone into the Markers TG Your Scenegraph should now look like this. If you haven’t already got an outline of your proposed field area then I suggest you make one using the Terrain Detail Texture Mode and a suitable texture. Once you have a field border then CTRL ‘B’ the newFieldMarkers transform into the field area. Note: The newFieldMarkers transform MUST be placed in a position that allows ALL the field boundary to be seen from that position (the cone in the newFieldMarkers TG will provide a reference point) otherwise the script will not work correctly, so for complicated field shapes you will have to create the fieldDimensions manually or by using FieldDimensionsWithBitmap script available from here https://ls-modcompany.com/forum/thread/5852-fs19-ge-script-fielddimensions-per-bitmap/ Also the Markers (cones) must be in a consecutive order, so if you have to add any additional markers to your layout (after creating one) then the extra marker must be placed in between existing ones in the Markers TG as the script uses each marker in turn to create the field Dimensions. Place the ‘cones’ along the edge of the field by CTRL ‘D’ (copy existing cone)-CTRL ‘B’ (place new cone) at suitable points as shown in the following image ( I have scaled the cones up for better definition). Using the fields transform in the fieldsNew TG to create the new field dimensions. In the Enter Field Number box enter the field number you want for this field. Now, first selecting the fields transform and holding Ctrl key select the Markers transform, releasing the Ctrl key and select the Create Field Dimension button. The new field dimensions together with the fieldMapIndicator will be created in the fields TG in the fieldsNew TG, if they are not visible in GE then with the fields TG selected Select – Scripts – Map –Toggle Render Field Areas and they should appear in GE. A Created Field Dimension for Field ‘field01’ message will also appear in the console log (field number will change to field created in subsequent operations). Results shown in following image. The script sets the default for fieldGrassMissions and fieldMissionAllowed to false. To change this to your prefered setting select the field number transform (field01 in the folowing image) And select the relevant box as shown below. fieldAngle can be left at 0, fieldDimensionIindex and nameIndicatorIndex refers to their position in the field(01) transform group 0 and 1 respectively. Painting the Field and adding details to farmlands.xml There are some tasks and settings to be done before this can be carried out. Firstly if you are starting from scratch then I suggest you ’Wipe’ the infoLayer_farmlands.grle if you already have fields painted then skip this next step. ‘Wipe’ infoLayer_farmlands.xml In GE zoom out until the whole map area (I use a pda camera for this ) is in view select the Terrain info Layer Paint Mode and in the Info Layer Painting panel select farmland in the drop down, select all the info channels (1-7). In the Terrain Editing Brush panel set a radius of 1000 and Brush Type square, paint the whole map area (ensure it is completely covered otherwise you will get errors in the log) and save the map. farmlands.xml If you have renamed your farmlands .xml then obviously use that name in the following and check the note in the Create Farmlands section regarding filePaths. Navigate to where the map.xml is located in your map normally Map Name/maps/mapUS (orFR/alpine) And open this in notepad++ and locate the <farmlands filename entry in this case it is <farmlands filename="$data/maps/mapUS/farmlands.xml" /> Change this to <farmlands filename="maps/mapUS/farmlands.xml" /> if you want to keep your farmlands.xml in the default position However I am going to put my farmlands.xml in a separate xml folder so my <farmlands filename entry will look like this <farmlands filename="maps/mapUS/xml/farmlands.xml" /> with the farmlands.xml placed in the new xml folder. Save the maps.xml. Open the farmlands.xml in notepad++ and ensure the path to the infoLayer_farmland.grle is correct the densityMapFilename should read densityMapFilename="maps/mapUS/data/infoLayer_farmland.grle" If you are starting from scratch open farmlands.xml and delete all the farmland entries like so. However if you already have fields created in the farmlands.xml then only delete any entries that have not yet been created leaving only the created ones e.g A second set of field Dimensions now need to be created in the fieldDimensions TG using the original set of markers. Select each of the field border markers in turn and move them to the outside of the field boundary (or if you have two fields that you want to have as one farmalnd area, to the outside of the whole area) Remember if you add any new markers the extra marker must be placed in between existing ones in the Markers TG as the script uses each marker in turn to create the field Dimensions. Once done first select the fields transform in the fieldDimensions TG and holding the Ctrl key select the Markers TG release the Ctrl key and select the Create Field Dimension button. Note: the field number is left as 1 in the Create Field Dimension script because this is the field number to be painted. Create Farmlands To paint the field infoLayer_farmland_grle and create the correct entries in the farmlands.xml in Giants Editor Select –Scripts, select the Field Dimensions and Farmlands folder to open it and then select the Create Farmlands Panel script, a popup Panel will appear on your screen. Set Land Price Scale- Enter your chosen price scale multiplier default is 1 Set NPC Area- Enter your chosen NPC area "ALPINE", "US" or "FR" Number of Different NPC’s Number of different NPC's (found in base maps npc.xml normally default 15) The npc number is randomly selected between 1 and the npcCount value in the script. Show on Farmlands Screen Default is true --false will stop field being shown on farmlands screen i.e showOnFarmlandsScreen="false" /> <!-- BGA, farmland bought via placeable --> When true the game scripts automatically show the farmlands so no showOnFarmlandsScreen entry will appear in the farmlands.xml Default Farm Property Default is false --true assigns ownership of field to player farm i.e defaultFarmProperty="true" /> Once you have made the relevant settings in the Panel , with the field01 TG (farmlandDimensions – fields - field01) selected, select the Create Farmlands button. Note: If your map has a non standard heiarchy or extra custom NPC characters then you will need to adjust some variables in the script, obviously if the map is a standard layout then this section can be ignored. The variables to change are, local farmLPath = {"farmlands.xml","xml/farmlands.xml"} – these are the normal places where the farmlands.xml is found. The script will automatically search for the xml in the following locations Main map folder Main Map/maps folder Main Map/maps/mapUS (orAlpine,FR) folder If your farmlands.xml has another name or placed in a different folder location then add this to the ‘farmLPath array ‘ not forgetting the quotes. local areas ={"ALPINE","US","FR"} – If you have another set of custom characters at a different location then add this to the ‘areas’ array again not forgetting the quotes. local npcCount = 15 -- If you have more custom characters then increase this number to the new amount. To carry out any of the above changes open the script in the GE Script Editor Window – Script Editor -- Field Dimensions and Farmlands - Create Farmlands Panel At the top of the script (lines 12,13,14) you will find these variables, adjust as necessary and save the script. The Script Editor can now be closed as it is no longer needed and the script is ready for use. The image below shows the resultant farmland painted (in Brown) with the farmlandDimensions overlayed in green. The inset shows the same farmland but selecting Farmland 1 in the Lands dropdown and show unmasked selected (removes the background colour) A INFO : Farmland id 1 Painted and farmlands.xml entry created message will also appear in the console log (field Id will change to any new Id created for subsequent fields). Note: Colours will vary as the Toggle Render Field Areas script randomly assigns colours to fields And the new entry in the farmlands.xml showing field 1 as belonging to the farm. You can create the fields in any order the script will adjust the farmlands.xml numerical order automaticaly and insert the next number in the appropriate place replacing the <farmland/> with the new field entry as shown below. If you try to create/paint a field ID that already exists then a warning will appear in the Console panel window and the existing farmland ID will not be overwritten , for example, +++++++++++++++++++++++++ Farmland ID 25 already exists in farmlands.xml Delete farmland Id 25 in the farmlands.xml if you wish to create a new farmland at Id 25 +++++++++++++++++++++++++ Should you wish to increase/decrease the size of the painted farmland area then in GE with the Terrain Layer Info Paint Mode selected and the farmland selected in the drop down in the Info Layer Painting Panel With the cursor over the area you wish to change select Ctrl ‘R’ on the keyboard and the correct farmland entry will appear in the Info Layer Painting Panel ready for you to paint Once happy save the map (sets the infolayer_farmland.grle) Painting Field Ground Type and Foliage This requires the Paint Field Ground Foliage Panel script. The script requires the correct Farming Simulator 2022 installation path, it uses a default path of "C:/Program Files (x86)/Farming Simulator 2022/". If your installation path is different then open the script in the GE Script Editor Window – Script Editor -- Field Dimensions and Farmlands - Paint Field Ground Foliage Panel At the top of the script at line 24 there is the following local gInst = "C:/Program Files (x86)/Farming Simulator 2022/" replace the "C:/Program Files (x86)/Farming Simulator 2022/" with your file path (including the quotes) and save the script. The Script Editor can now be closed as it is no longer needed and the script is ready for use. This script uses the created field dimensions to allow the painting of the Ground Type and Foliage to the field dimension area With the map open in GE select Scripts select the Field Dimensions and Farmlands folder then the Paint Field Ground Foliage Panel script the following pop up panel will appear on your screen Set Foliage Layer Select the Set Foliage Layer box and a dropdown will open listing all the various foliage layers in your map for example 'terrainDetail' Set Foliage State Only applies if terrainDetail not selected in the Set Foliage Layer. The number entered corresponds to the position of your chosen foliage state in the Layer State dropdown in the Foliage Layer Painting Panel of GE. To assist with finding the relevant foliage state all the foliage states for each ‘crop’ are printed in the console log and also in a foliage_states.txt file in the map.i3d folder Ground Type Selected from the Ground Type dropdown (all available terrain detail ground type’s listed). Ground Angle-Degrees Selected from the Ground Angle-Degrees dropdown (all available ground angles listed). Spray Types Selected from the Spray Type dropdown (all available spray types listed) Paint Ground/Foliage Executes the script Once you have entered your chosen settings with the field TG (i.e. field01) selected, select the Paint Ground/Foliage button Note: the Spray type works the same as if painted in GE so you will still get the requires lime/etc in the in game field info gui. The images below show console log print out for foliage states and the Paint Field Ground Foliage Panel settings for, Set Foliage Layer --terrain detail, Ground Type Ridge, Ground Angle -90,Spray Type Manure. Set Foliage Layer- potato, Foliage State - 5 (green big) Ground Type/GroundAngle/Spray Type left as previous as they have no effect if terrainDetail not selected. To erase/change any option select the foliage layer you want to change and either deselect it (blank) to remove or choose another foliage type , the same applies to the other options. For example selecting terraindetail and deselecting (blank) in the other setting(s) to be erased and selecting the Paint Ground/Foliage button will revert the field to the original ground texture ( in this case ‘dirt’) To remove foliage , select that foliage in the Set Foliage Layer dropdown and enter ‘0’ in the Foliage State select the Paint Ground/Foliage button will remove all the foliage of that selected Foliage Layer The script will work on any TG that has field dimensions so for example can be used to fill a predefined area that has been created using the field dimensions script. Note : Density Map Modifier details will also be printed in the log whenever the Paint Ground/Foliage script is used, this is not an script error but a GE info regarding number of channels e.g. DensityMapModifier: defaulting num channels to 10 DensityMapModifier: called from =C:/Users/Admin/AppData/Local/GIANTS Editor 64bit 9.0.6/scripts/PanelScripts/Field Creation Scripts/Paint Field Ground Foliage V4.lua (275) If manually painting the terrain detail a little tip, in the Limit to Texture drop down in the Foliage Layer Painting panel select the texture of your field area this will restrict the painting to that texture only and not paint over the grass border texture the image below shows the effect of these settings. To create other fields repeat the above methods. Once you have completed all your fields then, if starting from scratch cut/paste the fields TG from the fieldsNewTG to the gameplay TG replacing original. However if you already have fields created then copy/paste the fields TG from the fieldsNewTG to the gameplay TG and move any existing fields into the new field TG. Save the map. --------------------------------------------------------------------------------------------------------------- Method 2 Using a Spline This method is more or less the same as the first except I will be using a spline to create the field border and place the markers, the placedObjects TG will be used instead of the Markers TG when creating the field Dimensions. The scripts used in this section of the tutorial are:- Spline Placement set –Transform/Place/Delete Sets the required transform groups in the scenegraph Places objects along a spline Option to delete the current placed objects Create Field Dimension Panel Creates field dimensions from markers Create Farmlands Panel Paints the InfoLayer farmlands.grle and adds relevant data to the farmlands.xml. Paint Field Ground Foliage Panel Paints the chosen Ground Type (i.e.Plowed,Cultivated etc) and Foliage at a chosen state (i.e. wheat, harvest ready). Spline Paint Panel Paints chosen texture(s) along/either side of a spline If you haven’t used the Spline Placement scripts/ Spline Paint Panel scripts before then I suggest you have a look at the tutorials linked below. https://farmerboysmodding.com/index.php?/topic/2414-terrain-height-paint-terrain-and-spline-placement-scripts-tutorials/ Initial set up When using scripts in GE that do not require access to the script editor (such as the Toggle Render Field Areas) what I normally do is go to Scripts –Map, which opens the folder at the bottom of the popout is Detach Menu, selecting this undocks the folder from the Scripts list which can then be place anywhere on the screen or redocked into the side panels (see images in the tutorial for examples). Open map in GE, open Script Editor (Window – Script Editor) select and execute the following script (found in the Spline Placement folder):- SplinePlacement Transform – this will create the necessary transform group heirachy for the script In GE create a spline (Create—Spline) and cut paste it into the splinePlacement transform. Create a primitive (Create—Primitives) again I will be using a cone, and copy/paste one into the objectsTo Place transform and another into the splineObjects transform (this one is used as a guide for the fieldMapIndicator) . I will be using the exsisting transform group farmlandDimensions TG from the previous method infoLayer_farmlands.grle and farmlands.xml set up is the same as previous method. The splineObjects transform will be used to create a field boundary and place the markers, the spline itself will also be used to paint a field border in a suitable texture The farmlandDimensions TG with the fields transform will be used to create a second set of fieldDimensions in a new (in this case ) field02 transform to be used for painting the infoLayer_farmland.grle and creating a new entry in the farmlands.xml in the same way as before. Creating Field Dimensions These are created much the same way as the before the exception is now the field boundary is created using a spline. Select the splineObjects TG place it into the field by Ctrl ‘B’ , again the whole field boundary must be visible from the chosen location. Select the spline and place it in a suitable postion on the field boundary (I have chosen the top right corner and have also deleted the ‘S’ cv to forestall any rotation problems with the spline) and using just the ‘E’ cv create the field boundary (to get sharp corners insert an extra cv before continuing along the boundary). Once the boundary has been completed the field border can be painted by selecting the spline in the splinePlacement TG and in GE -- Select - Scripts—Spline Paint Panel the following image shows the panel set up for this particular field edge. This will paint a 5m ROUGHGRASS border to the left of the spline (viewed from the ‘S’ cv). The script reads all the various textures from the map.i3d and assigns them (in order) in the relevant dropdowns. You can of course select your own texture from the dropdown any texture/area you do not want painted the -1 must be selected. If required you can now easily paint the field texture (DIRT) itself by using the Limit to Texture method described earlier. With the border now painted select the splinePlacement transform to bring up the splinePlacement User Attributes and set the User Attributes as follows, Set Object Distance – 20 -- This can be set to any suitable number as long as the complete field border covered Fixed Distance --Selected –Enables items to be placed a fixed distance away from the spline Set Distance Fixed -- -5 --Is the distance objects will be placed away from the spline in this case - 5 m to allow for a 5m field border ( - 5 to the left of the spline viewed from the ‘S’ cv) other settings can be left as default. With the splinePLacement TG selected and the Spline Placement script selected either in the Script Editor or from the Detached Panel execute the script, (I have scaled the cone by 4 and freeze transformed for clarity). This image shows the field border painted together with the cones placed around the field perimeter The next step is to thin the cones out by deleting unnecessary ones (either one by one or left click drag to select multiples) and adjusting the position of others for better shaped field dimensions, in the next image the inset shows the the cones thinned out and the field dimensions created after entering field number then first selecting the fields transform (in the fieldsNew TG) and holding the Ctrl key select the placedObjects TG, release the Ctrl key and in the Create Field Dimension Panel select the Create Field Dimension button Note any other field dimension already created will also show when selecting Toggle Render Field Areas Next to create the second set of farmlandDimensions first select the spline Placement TG and in the Script Editor select Spline Placement Delete, in the Spline Placement folder (this will execute the script) In the Spline Placement User Attributes change the Set Fixed Distance to 2 (this will place the cones 2m outside the spline) and with the Set Object Distance still at 20 select Spline Placement, again adjust the position of the cones to create a smooth path around the field border If creating the fields farmlandDimension next to one already created then to ensure no gaps in the painting between the fields in the infoLayer_farmland.grle, with the fields TG ( in the farmlandsDimension TG) selected, select Scripts - Map – Toggle Render Field Areas, this will show all the farmlandDimension currently created. Then adjust the cones so that they align with the other fields farmlandDimensions, the following image shows an example of this in the inset. Once done, in the Create Field Dimension Panel leave the field number the same as the one for field dimensions first select the fields TG ( in the farmlandsDimension TG) and holding the Ctrl key select the placedObjects TG and select the Create Field Dimension button. The newly created field02 farmlandsDimension created Painting field infoLayer_grle and farmlands.xml This is done in the same way as the previous tutorial. Open the Create Farmlands Panel (Scripts - Field Dimensions and Farmlands - Create Farmlands Panel ) Set the options as required then in the fields TG ( in the farmlandsDimension TG) select (in this case) field02 and then the Create Farmlands button to execute the script. The image below shows the new field02 farmland painted in the infoLayer_farmland.grle (Terrain Info Paint Mode selected) together with the previous field01 creation. And in the farmlands.xml the following settings. Painting the Ground Type and Foliage State can be done using the Paint Field Ground Foliage script as described earlier in the tutorial in the Painting Field Ground Type and Foliage section. The spline can now be used to add fences/foliage/hedges etc by using the releveant scripts Fence Power Placement Paint Foliage by Spline Spline Placement All the above can be found in the relevant tutorials on the forum and are include in the Field Dimensions and Farmlands folder The following is an example using the Spline Placement. Adding hedges etc Delete the cones in the placedObjectsTG (with the splinePlacement TG selected, select and execute the Spline Placement Delete script) . Replacing the cone in the objetsToPlace TG with a 4m hedge from the in game foliage-hedge folder and setting the Set Object Distance to 4m with the splinePlacement TG selected execute the Spline Placement Script. Delete the 4m hedge from the objectsToPlace TG and replace it with a pagoda dogwood tree (or another of your choice) and reset the Spline Placements User attributes to Execute the spline Placement script Once happy with the reults then copy paste the placedObjects TG to another part of the Senegraph and rename and with the splinePlacement TG selected execut the Spline Placement Delete script to clear the placedObjects TG if required. Image below shows the result with the farmland painted with a wheat foliage texture in Giants Editor NOTE: At this point If using a fields Transform Group other than the default one in the maps gameplay TG do not forget to cut/paste the new fields TG to the correct place in the maps gameplay TG before saving the map. Also the fieldMapIndicator can now be moved to a different location if required as it is no longer used as a reference point for the scripts. With the map saved and then opened in game the following image shows the farmlands screen with farmland 01 selected showing field area with number and price. In game showing NPC details Finally field User Attributes if you want a particular field to have grass missions then all you have to do is select the fieldGrassMission option in the relevant field User Attribute in this case field01. Installation of scripts To install unzip the file and copy/paste the Field Dimensions and Farmlands folder into. C:/Users/Your Computer Names/AppData/Local/GIANTS Editor 64bit 9.0.6/scripts Note: Panel scripts can only be used with GE 9.0.6 if using earlier versions of the GE Editor then download the 'Archive Field Dimensions and Farmlands.zip' which also contains a web page copy of the old tutorial for reference. Field Dimensions and Farmlands.zip Archive Field Dimensions and Farmlands.zip
    1 point