-- author: DD ModPassion
-- copyright (C): DD ModPassion, All Rights Reserved
-- version: Farming Simulator 22
FixSupportVehicle = {} local modDirectory = g_currentModDirectory or "unknown" function FixSupportVehicle.prerequisitesPresent(specializations) return SpecializationUtil.hasSpecialization(SupportVehicle, specializations) end function FixSupportVehicle.registerEventListeners(vehicleType) SpecializationUtil.registerEventListener(vehicleType, "onLoad", FixSupportVehicle) end function FixSupportVehicle:onLoad(savegame) local spec = self.spec_supportVehicle local baseKey = "vehicle.supportVehicle" local filename = self.xmlFile:getValue(baseKey.."#filename") if filename ~= nil then spec.filename = Utils.getFilename(filename, modDirectory) end if savegame == nil or self:getInputAttacherJointIndexByNode(1) == 1 then spec.firstRun = false end SpecializationUtil.removeEventListener(self, "onDelete", SupportVehicle) end function FixSupportVehicle:onPostDetach(attacherVehicle, implement) if not self.isDeleting and self:getInputAttacherJointIndexByNode(1) == nil then local spec = self.spec_supportVehicle self:addSupportVehicle(spec.filename, spec.inputAttacherJointIndex, spec.attacherJointIndex) end end