Community Forum

Mod Namespaces

Forum Overview >> Farming Simulator 2011

CategoryFarming Simulator 2011
Created01.08.2011 21:36

Saracaen (saracaen) 01.08.2011 21:38
I have created a mod that appends some new functions to the Steerable class, but it interferes with some of the functions of the ESLimiter specialization.

Is there a way to identify that the ESLimiter specialization is present in the current steerable, so that I can disable my interfering function?

Stefan Geiger - GIANTS Software 02.08.2011 09:04
Yes, you can check this with the following code:

if g_modIsLoaded["ESLimiter"] then
-- the mod with the .zip name "EsLimiter" is loaded.

Saracaen (saracaen) 02.08.2011 18:58
Thanks for the quick reply, although that is not exactly what I meant.

I have created a script that injects a piece of code in every object containing the Steerable specialization. That script interferes with some other specializations and I want to be able to check if these specializations are present in the current steerable.

Is there a way to identify if , for example, the ESLimiter specialization is present on the current Steerable?

Saracaen (saracaen) 03.08.2011 20:37
On, for example, the Fendt 380 GTA, the ESLimiter specialization is prepended with the mod namespace. So it would be Fendt380GTATurbo.ESLimiter.

Is there a way to prepend this "namespace" to the SpecializationUtil.hasSpecialization function call?

Saracaen (saracaen) 04.08.2011 21:34
I have found a solution:

"local check1 = Utils.getNoNil(getXMLBool(xmlFile, "vehicle.features#vario"), true);
self.isVarioEnabled = check1;

if self.customEnvironment ~= nil then
local specialization1 = loadstring(string.format("return %s.ESLimiter", self.customEnvironment))();
local specialization2 = loadstring(string.format("return %s.rpmlimiter", self.customEnvironment))();

local check2 = SpecializationUtil.hasSpecialization(specialization1, self.specializations);
local check3 = SpecializationUtil.hasSpecialization(specialization2, self.specializations);

self.isVarioEnabled = check1 and not check2 and not check3;

Due to the use of loadstring, it might not be optimal. If anyone has a better solution, please let me know.

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