Community Forum


Forum Overview >> Scripting

Created21.01.2021 20:29

Jack Arrow (JackArrow) 21.01.2021 20:29
Hey Everyone,

I´m working on .lua that manipulates the forageharvester yield for Maize in fruitTypeConverters.
In fruitTypes.xml it looks like:
<fruitTypeConverter name="FORAGEHARVESTER">
<converter from="MAIZE" to="CHAFF" factor="7.8" />

Can anybody explain to me how i can change the factor in the fruitTypeConverters for maize from 7.8 to another value by using lua-script?

Thanks a lot!

Bilbo Beutlin (BBeutlin) 21.01.2021 22:04
Why lua script? Simply setup the factor in a modmap's fruitTypes.xml.

With scripting there are several methods.
- global overwrite the value, results in same as change fruitTypes.xml, so why?
- change it for a certain vehicle class/specialization, needs overwriting certain spec functions
- change it for a special vehicle, needs adding a new spec

At least the two last methods require advanced knowledge and experience.

Jack Arrow (JackArrow) 21.01.2021 22:43
i want to overwrite it globaly.
i already did it for values of filltypes and fruittypes but the structure of the converters is not the same i think
i tried something like:

for n, z in pairs(g_currentMission.fruitTypeManager.fruitTypeConverters) do
z.factor = 8;;

but it was not successfull

Bilbo Beutlin (BBeutlin) 21.01.2021 23:15
Global overwriting will only work at a certain point in time.
If you do it too early, it will be overwritten by the map's "fruitTypes.xml".
If you do it too late, the values were copied already into the spec's internal table.

Jack Arrow (JackArrow) 22.01.2021 00:36
Thanks for all your worrys, but thats not the point. I got an infrastructure that works fine allready.
I use the addModEventListener()
As i sad, with values of filltypes and fruittype like yield it works very well.
Or wouldnt it be the same with the converter factors?

the thing i need is the right "adress" to change the factor of the forageharvester
I know that somehow you can adress it like this, maybe?


i didnt found any information of the structure of the data or how to adress them to change the factor.
Do you know how to?

Bilbo Beutlin (BBeutlin) 22.01.2021 01:21
The infos are in LUADOCS, you didn't search thoroughly.

I think it's not the same, since fillTypes and fruitTypes as well as this categories are not loaded into an internal spec table.

See eg. Cutter.lua or Mower.lua function onLoad() for reference. There you'll find also examples for usage of 'fruitTypeConverters'.

At least you cannot simply use something like: if name == FORAGEHARVESTER - this is a string and must be enclosed in quotes.

For general reference see LUADOCS/scripts/misc/FruitTypeManager.lua

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