Community Forum

FS22 VehicleTypeManager error

Forum Overview >> Scripting

CategoryScripting
Created23.11.2021 19:07


Olivier Beauchemin (obeauchemin) 23.11.2021 19:07
I can't find the LUA documentation for FS22, so I take my chance here.
Does anybody know if this variable has switched name?

-----
BoostFuelConsumption.lua:67: attempt to index global 'VehicleTypeManager' (a nil value)
-----

VehicleTypeManager.validateVehicleTypes = Utils.prependedFunction(VehicleTypeManager.validateVehicleTypes, IncreasedFuelConsumption.installSpecializations)

Thanks for the help!

Bilbo Beutlin (BBeutlin) 23.11.2021 20:20
The FS22 LUA sources (gameSource.zip) are distributed with the game installation.
See in your FS game install folder "sdk/debugger" as well as in your FS user folder "debugger".

Besides, it is to be expected that these become updated with recent patches. So a very nice idea to provide us with the most actual infos.

Olivier Beauchemin (obeauchemin) 24.11.2021 01:17
Are you sure? I have only one file in these two folders: scriptBinding.xml, unfortunately, nothing else.

EDIT: Okay, I just found the gameSource.zip on my Dedicated Server. This file is only available when you bought it on Giant. My personal copy is on Steam, and the Dedi Server's copy has been purchased on Giant. Thanks for your help! :)

Bilbo Beutlin (BBeutlin) 24.11.2021 02:47
Then it's most probably Steam specific. I have the standard DVD version. But maybe the SDK files were installed afterwards by the game updater together with the day-one patch.

Olivier Beauchemin (obeauchemin) 24.11.2021 03:20
It seems that VehicleTypeManager is not a global variable anymore.
I saw somewhere in Vehicle.Lua that you could use "g_vehicleTypeManager". I don't have any error anymore, but my overwritten function doesn't work, the print_r inside is not executed.

g_vehicleTypeManager.validateVehicleTypes = Utils.prependedFunction(g_vehicleTypeManager.validateVehicleTypes, BoostFuelConsumption.installSpecializations)

Any tips are welcome. I really need to know what have happen to VehicleTypeManager.

André Buchmann (schliesser) 24.11.2021 09:24
Oh, thats good to know that there is a "gameSource.zip" file. Unfortunately I have the game only on steam. Luckily there is a way to extract them from the dataS.gar :-)

@Oliver The Class VehicleTypeManager doesn't exist anymore. There is a more generic class called "TypeManager" now. This class has the method: "validateTypes"

Try:
TypeManager.validateTypes = Utils.prependedFunction(TypeManager.validateTypes, IncreasedFuelConsumption.installSpecializations)

As the new TypeManager now handles vehicles and placeable objects, you may need to change your code, to run only on vehicles.

g_vehicleTypeManager = TypeManager.new("vehicle", "vehicleTypes", "dataS/vehicleTypes.xml", g_specializationManager)
g_placeableTypeManager = TypeManager.new("placeable", "placeableTypes", "dataS/placeableTypes.xml", g_placeableSpecializationManager)

Majo76 24.11.2021 13:50
If you require a table of vehicle types, just use "g_vehicleTypeManager.types"

--
Majo76 / ZhooL
Author of: EnhancedVehicle

Bilbo Beutlin (BBeutlin) 24.11.2021 22:46
Like already mentioned above, the "vehicleTypeManager" has become a general "typeManager".
In the source codes it is referenced only few times with "g_vehicleTypeManager:getTypeByName()", perhaps for backward compatibility.

You could try with "TypeManager:getTypes()" what simply returns the 'self.types' array.

Anyway, don't forget the FS22 is still in development and things may change very soon. ;)

Peter Harder (PeterAH) 25.11.2021 00:54
I have FS22, Version 1.1.1.0 (pre-downloaded friday)

“g_vehicleTypeManager.types” works very well, even “types” is not shown by “printTableRecursively()”, what I didn’t understand.

“TypeManager:getTypes()” didn’t work at all, and it’s never used from Giants in the given Lua files. The Problem is, that the function because of the colon is expecting self as first parameter. If you call the function, “self” is from the calling function and not the self of TypeManager, what is needed. Below the not working function.

function TypeManager:getTypes()
return self.types
end


Olivier Beauchemin (obeauchemin) 25.11.2021 07:37
@André Wow thank you mate, it works perfectly! :)

André Buchmann (schliesser) 25.11.2021 13:33
@Oliver You're welcome! :-)

Stipa Stipica (WiseBit) 26.11.2021 23:28


Odrien 27.11.2021 11:56
hi @André Buchmann (schliesser), thanks for your help, being new to Lua coding would you be so kind as to help me convert "Simple IC" mods?

D3rBay3r 30.11.2021 00:30
@André can you tell me how you extracted the gameSource.zip from the dataS.gar ?
"Luckily there is a way to extract them from the dataS.gar :-)"

:)

Vincent Le Bartz (vincentlb) 29.12.2021 10:15
bonjour j aimerai convertir le mods simple ic fs 19 en fs22 , quand je le met dans mon dossier mods et que je lance le jeu il me met cette erreur

Error: C:/Users/vleba/Documents/My Games/FarmingSimulator2022/mods/FS22_simpleIC/registerSimpleIC.lua:8: attempt to index global 'VehicleTypeManager' (a nil value)

ducoup j ai enlever a 'VehicleTypeManager le Vehicle et j ai redemarrer le jeu en ayant enregistrer et il me met plus l erreur mais il ne marche pas pour autant qui pourrait m aider s il vous plait ?


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