Community Forum

Adding fruitTypeConverter with mod that is not a map

Forum Overview >> Farming Simulator 19

CategoryFarming Simulator 19
Created21.06.2021 18:08

Xp Modding (XPModding) 21.06.2021 18:08
I want to create a onion harvester mod, that is intended for maps that already add the onions as fruittypes and filltypes and so on.
Due to the way the harvester works (it gets the onions out of the ground and cleans them and then puts them on to the ground) I want to implement the harvester as a "mower".
I understand that the mower specialization uses a fruitTypeConverter specified by name in the implements xml file.
Therefore I now want to create a new fruitTypeConverter that simply converts Onion to Onion.

Here is what I have:
<fruitTypeConverter name="ONIONHARVESTER">
<converter from="Onion" to="Onion" factor="1.0" windrowFactor="1.0" />

My question now is: How do I get this new fruitTypeConverter to register correctly?

As I am not creating a map I can't add it to the maps fruitType.xml file, where it would normally go.

I tried to do it directly in the modDesc, but that doesn't work.

Also: Is there maybe a lua method for adding a new fruitTypeConveter to fruitTypeManager?

Xp Modding (XPModding) 21.06.2021 19:01
Ok. found it out by myself now.

I wrote a lua script that appends a new function to fruitTypeManager.loadMapData and in that appended function i simply call XMLUtil.loadDataFromMapXML with a new xml file and all the other parameters the same as in fruitTypeManager.loadMapData.

The new xml file can be basically a normal map fruitType.xml, so I guess this could be used for other things as well.

The script seems to work since it does correctly register the new fruitTypeConverter.

Here is my script for anyone who might be interested:

path = tostring(g_currentModDirectory.."fruitTypeConverter.xml")

function registerFruitTypeConveter(xmlFile, missionInfo, baseDirectory)

return XMLUtil.loadDataFromMapXML(loadXMLFile("fruitTypeConverter", path), "fruitTypes", baseDirectory, g_fruitTypeManager, g_fruitTypeManager.loadFruitTypes, missionInfo)


FruitTypeManager.loadMapData = Utils.appendedFunction(FruitTypeManager.loadMapData, registerFruitTypeConveter)

Note: Log in to post. Create a new account here.