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)

illgib81 02.02.2024 13:23
Hi, sorry for the huge necro but i have a very similar problem that i can't solve, plus i know nothing about lua or scripting in general.

I modified the game original files to have a new cotton mower into the fruitType and it works pretty well, but i'm trying to fix and clean making into a custon fruitType inside the mod, so i don't have to fiddle with it every game update, but he completely ignore it.

My ModDesc

<en>Cotton equipement</en>

<en>A mower and a baler for small cotton bales. Usefull in smaller farms.</en>


<storeItem xmlFilename="gmd3123F.xml"/>
<storeItem xmlFilename="impress125FPro.xml"/>

<fruitTypes filename="cotton_fruitTypes.xml" />

<bale filename="cotton_roundbale.xml" />

and the custom fruitType

<fruitTypeConverter name="MOWER_COTTON">
<converter from="COTTON" to="COTTON" factor="6.0" windrowFactor="1.0" />

It buffle me that fillTypes it's read from modDesc, (even if it's not needed anymore, the baler accept the vanilla cotton filltype) but the fruit it's ignored.

I tried your script but nothing happen neither, in any case it won't even log any warning or error, he does nothing, doesn't cut the cotton.
If i remod the original file it work fine.
It's not a big deal, i'm not playing online and i can edit the missing lines when an update occur, but if i wanna publish it i can't.

Any help would be greatly appreciated, and Google it's utterly useless.

I forgot, i'm modding into FS22, don't know if anything changed.

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