LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

HookLiftContainer

Description
Specialization for hooklift containers to be attached/loaded up on a hooklift trailer
Functions

getCanDischargeToGround

Description
Definition
getCanDischargeToGround()
Code
72function HookLiftContainer:getCanDischargeToGround(superFunc, dischargeNode)
73 local attacherVehicle = self:getAttacherVehicle()
74 if attacherVehicle ~= nil and attacherVehicle.getIsTippingAllowed ~= nil then
75 if not attacherVehicle:getIsTippingAllowed() then
76 return false
77 end
78 end
79
80 return superFunc(self, dischargeNode)
81end

getCanDischargeToObject

Description
Definition
getCanDischargeToObject()
Code
59function HookLiftContainer:getCanDischargeToObject(superFunc, dischargeNode)
60 local attacherVehicle = self:getAttacherVehicle()
61 if attacherVehicle ~= nil and attacherVehicle.getIsTippingAllowed ~= nil then
62 if not attacherVehicle:getIsTippingAllowed() then
63 return false
64 end
65 end
66
67 return superFunc(self, dischargeNode)
68end

initSpecialization

Description
Called on specialization initializing
Definition
initSpecialization()
Code
23function HookLiftContainer.initSpecialization()
24 local schema = Vehicle.xmlSchema
25 schema:setXMLSpecializationType("HookLiftContainer")
26
27 schema:register(XMLValueType.BOOL, "vehicle.hookLiftContainer#tiltContainerOnDischarge", "Tilt container on discharge", true)
28
29 schema:setXMLSpecializationType()
30end

isDetachAllowed

Description
Definition
isDetachAllowed()
Code
85function HookLiftContainer:isDetachAllowed(superFunc)
86 local attacherVehicle = self:getAttacherVehicle()
87 if attacherVehicle ~= nil and attacherVehicle.getCanDetachContainer ~= nil then
88 if not attacherVehicle:getCanDetachContainer() then
89 return false, nil
90 end
91 end
92
93 return superFunc(self)
94end

onLoad

Description
Called on loading
Definition
onLoad(table savegame)
Arguments
tablesavegamesavegame
Code
51function HookLiftContainer:onLoad(savegame)
52 local spec = self.spec_hookLiftContainer
53
54 spec.tiltContainerOnDischarge = self.xmlFile:getValue("vehicle.hookLiftContainer#tiltContainerOnDischarge", true)
55end

onStartTipping

Description
Definition
onStartTipping()
Code
98function HookLiftContainer:onStartTipping(tipSideIndex)
99 local spec = self.spec_hookLiftContainer
100 local attacherVehicle = self:getAttacherVehicle()
101 if attacherVehicle ~= nil and attacherVehicle.startTipping ~= nil and spec.tiltContainerOnDischarge then
102 attacherVehicle:startTipping()
103 end
104end

onStopTipping

Description
Definition
onStopTipping()
Code
108function HookLiftContainer:onStopTipping()
109 local spec = self.spec_hookLiftContainer
110 local attacherVehicle = self:getAttacherVehicle()
111
112 if attacherVehicle ~= nil and attacherVehicle.stopTipping ~= nil and spec.tiltContainerOnDischarge then
113 attacherVehicle:stopTipping()
114 end
115end

prerequisitesPresent

Description
Checks if all prerequisite specializations are loaded
Definition
prerequisitesPresent(table specializations)
Arguments
tablespecializationsspecializations
Return Values
booleanhasPrerequisitetrue if all prerequisite specializations are loaded
Code
17function HookLiftContainer.prerequisitesPresent(specializations)
18 return SpecializationUtil.hasSpecialization(AnimatedVehicle, specializations) and SpecializationUtil.hasSpecialization(Attachable, specializations)
19end

registerEventListeners

Description
Definition
registerEventListeners()
Code
42function HookLiftContainer.registerEventListeners(vehicleType)
43 SpecializationUtil.registerEventListener(vehicleType, "onLoad", HookLiftContainer)
44 SpecializationUtil.registerEventListener(vehicleType, "onStartTipping", HookLiftContainer)
45 SpecializationUtil.registerEventListener(vehicleType, "onStopTipping", HookLiftContainer)
46end

registerOverwrittenFunctions

Description
Definition
registerOverwrittenFunctions()
Code
34function HookLiftContainer.registerOverwrittenFunctions(vehicleType)
35 SpecializationUtil.registerOverwrittenFunction(vehicleType, "getCanDischargeToObject", HookLiftContainer.getCanDischargeToObject)
36 SpecializationUtil.registerOverwrittenFunction(vehicleType, "getCanDischargeToGround", HookLiftContainer.getCanDischargeToGround)
37 SpecializationUtil.registerOverwrittenFunction(vehicleType, "isDetachAllowed", HookLiftContainer.isDetachAllowed)
38end