Community Forum

Add a FillType in script with XML ?

Forum Overview >> Scripting

Created04.03.2019 17:01

PinchTheFarmer 04.03.2019 17:01
How can i load a new fillType with scripting ?? i made an XML file with fillTypes, and i am trying since 4 hours every function like FillTypeManager:loadFillTypes or g_fillTypeManager.addFillType with strings or XML handle file but it never work :/ always an error with string or other, can we have the input parameters of theses functions please ?

Bilbo Beutlin (BBeutlin) 04.03.2019 19:52
Why a lua script if it is much easier??
Simply add a file "newFillTypes.xml" to your map. See the "data/maps/maps_fillTypes.xml" for reference. This file is loaded always. You need only define your new fillTypes or those you want to change.
Your file you register in the map.xml <fillTypes filename="newfillTypes.xml" />

PinchTheFarmer 05.03.2019 00:46
Oh lol. No no no, it is not for a map, it is for adding new animals. But well this afternoon i suceed to do it :) check the new mod "Animal Species - Pig Pack" , it add x8 new pigs to buy !

But i added the fill types in brute force , well they are still adapted to their index & etc, but it would be easier to add them from a file xD , i also suceed to do AnimalManager.loadAnimals from an XML file but the big problem is that it replace all animals in fact :/

BUT if you gimme new models i will add very new animals. But for this maybe it will be better to wait 1.3 , we will be able to specify the pallet to produce , right ? Or i can make weird animal who produce liquidFertilizer or things like that lol ! XD i'm joking, i'll wait 1.3 for very new animals. I have that awesome mod to do, which is bzzzzz ----CLASSIFIED---- . Arg i can't tell :P

OH i know ! there are fillablePallets in original ! :O mmh some goat who produce Cotton, can be nice ?

Bilbo Beutlin (BBeutlin) 05.03.2019 11:53
In general the method of FS17 should still work. See FS17 LUADOC -> Utils -> FillUtil -> registerFillType
However now in FS19 you have to use the FillTypeManager instead.

Anyway it's a little tricky now to add fillTypes by script. One must choose the right point in time. It must be AFTER the fillType.xml is evaluated, but BEFORE the EconomyManager has been setup.
Dynamically ingame adding/removing fillTypes wouldn't work (most probably). That would confuse the engine and crashes are to be expected.

PinchTheFarmer 05.03.2019 13:54
Errr it can make crashes yeah :D But i'm looking tables and using INSERT then i get Indexes back to save them & etc, i make it nice :) But yeah its for that i ask what function it is to add them :D At the end it s not so hard, just printTables of g_fillTypeManager and you understand nice :)
ALSO you need to do copies of tables (take care in script VAR = TABLE will lead to a save of the pointer to the table in your VAR, it dont copy without custom functions).

But once you copy nice, insert dynamically & get back indexes to set up all tables as i did in Pig Pack, it work nice :) the engine can add fill types before or after, it will change nothing because i didn't hard-coded tables indexes.

Viper Gts (ViperGTS96) 27.05.2019 15:24
@PinchTheFarmer you may request this information @

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