LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

Roller

Description
Specialization for roller used for removing fields/terrainDetailLayer
Functions

doCheckSpeedLimit

Description
Definition
doCheckSpeedLimit()
Code
100function Roller:doCheckSpeedLimit(superFunc)
101 local spec = self.spec_roller
102
103 return superFunc(self) or spec.isWorking
104end

getDefaultSpeedLimit

Description
Definition
getDefaultSpeedLimit()
Code
205function Roller.getDefaultSpeedLimit()
206 return 15
207end

getDirtMultiplier

Description
Definition
getDirtMultiplier()
Code
115function Roller:getDirtMultiplier(superFunc)
116 local spec = self.spec_roller
117 local multiplier = superFunc(self)
118
119 if spec.isWorking then
120 multiplier = multiplier + self:getWorkDirtMultiplier()
121 end
122
123 return multiplier
124end

getDoGroundManipulation

Description
Definition
getDoGroundManipulation()
Code
108function Roller:getDoGroundManipulation(superFunc)
109 local spec = self.spec_roller
110 return superFunc(self) and spec.isWorking
111end

getIsWorkAreaActive

Description
Definition
getIsWorkAreaActive()
Code
142function Roller:getIsWorkAreaActive(superFunc, workArea)
143 if workArea.type == WorkAreaType.ROLLER then
144 local spec = self.spec_roller
145 if spec.startActivationTime > g_currentMission.time then
146 return false
147 end
148
149 if spec.onlyActiveWhenLowered and not self:getIsLowered() then
150 return false
151 end
152 end
153
154 return superFunc(self, workArea)
155end

getWearMultiplier

Description
Returns current wear multiplier
Definition
getWearMultiplier()
Return Values
floatdirtMultipliercurrent wear multiplier
Code
129function Roller:getWearMultiplier(superFunc)
130 local spec = self.spec_roller
131 local multiplier = superFunc(self)
132
133 if spec.isWorking then
134 multiplier = multiplier + self:getWorkWearMultiplier()
135 end
136
137 return multiplier
138end

initSpecialization

Description
Definition
initSpecialization()
Code
15function Roller.initSpecialization()
16 g_workAreaTypeManager:addWorkAreaType("roller", false)
17end

onDeactivate

Description
Definition
onDeactivate()
Code
197function Roller:onDeactivate()
198 local spec = self.spec_roller
199 g_soundManager:stopSample(spec.samples.work)
200 spec.isWorkSamplePlaying = false
201end

onDelete

Description
Definition
onDelete()
Code
74function Roller:onDelete()
75 if self.isClient then
76 local spec = self.spec_roller
77 g_soundManager:deleteSamples(spec.samples)
78 end
79end

onEndWorkAreaProcessing

Description
Definition
onEndWorkAreaProcessing()
Code
167function Roller:onEndWorkAreaProcessing(dt, hasProcessed)
168 local spec = self.spec_roller
169
170 if self.isClient then
171 if spec.isWorking then
172 if not spec.isWorkSamplePlaying then
173 g_soundManager:playSample(spec.samples.work)
174 spec.isWorkSamplePlaying = true
175 end
176 else
177 if spec.isWorkSamplePlaying then
178 g_soundManager:stopSample(spec.samples.work)
179 spec.isWorkSamplePlaying = false
180 end
181 end
182 end
183end

onLoad

Description
Definition
onLoad()
Code
54function Roller:onLoad(savegame)
55 local spec = self.spec_roller
56
57 XMLUtil.checkDeprecatedXMLElements(self.xmlFile, self.configFileName, "vehicle.rollerSound", "vehicle.roller.sounds.work") --FS17 to FS19
58 XMLUtil.checkDeprecatedXMLElements(self.xmlFile, self.configFileName, "vehicle.onlyActiveWhenLowered#value", "vehicle.roller#onlyActiveWhenLowered") --FS17 to FS19
59
60 if self.isClient then
61 spec.samples = {}
62 spec.isWorkSamplePlaying = false
63 spec.samples.work = g_soundManager:loadSampleFromXML(self.xmlFile, "vehicle.roller.sounds", "work", self.baseDirectory, self.components, 0, AudioGroup.VEHICLE, self.i3dMappings, self)
64 end
65
66 spec.onlyActiveWhenLowered = Utils.getNoNil(getXMLBool(self.xmlFile, "vehicle.roller#onlyActiveWhenLowered"), true)
67 spec.startActivationTimeout = 2000
68 spec.startActivationTime = 0
69 spec.isWorking = false
70end

onPostAttach

Description
Called after vehicle gets attached
Definition
onPostAttach(table attacherVehicle, integer inputJointDescIndex, integer jointDescIndex)
Arguments
tableattacherVehicleattacher vehicle
integerinputJointDescIndexindex of input attacher joint
integerjointDescIndexindex of attacher joint it gets attached to
Code
190function Roller:onPostAttach(attacherVehicle, inputJointDescIndex, jointDescIndex)
191 local spec = self.spec_roller
192 spec.startActivationTime = g_currentMission.time + spec.startActivationTimeout
193end

onStartWorkAreaProcessing

Description
Definition
onStartWorkAreaProcessing()
Code
159function Roller:onStartWorkAreaProcessing(dt)
160 local spec = self.spec_roller
161
162 spec.isWorking = false
163end

prerequisitesPresent

Description
Definition
prerequisitesPresent()
Code
21function Roller.prerequisitesPresent(specializations)
22 return SpecializationUtil.hasSpecialization(WorkArea, specializations)
23end

processRollerArea

Description
Definition
processRollerArea()
Code
83function Roller:processRollerArea(workArea, dt)
84 local spec = self.spec_roller
85
86 local xs,_,zs = getWorldTranslation(workArea.start)
87 local xw,_,zw = getWorldTranslation(workArea.width)
88 local xh,_,zh = getWorldTranslation(workArea.height)
89
90 local realArea = FSDensityMapUtil.updateRollerArea(xs, zs, xw, zw, xh, zh)
91 FSDensityMapUtil.eraseTireTrack(xs, zs, xw, zw, xh, zh)
92
93 spec.isWorking = self:getLastSpeed() > 0.5
94
95 return realArea
96end

registerEventListeners

Description
Definition
registerEventListeners()
Code
43function Roller.registerEventListeners(vehicleType)
44 SpecializationUtil.registerEventListener(vehicleType, "onLoad", Roller)
45 SpecializationUtil.registerEventListener(vehicleType, "onDelete", Roller)
46 SpecializationUtil.registerEventListener(vehicleType, "onPostAttach", Roller)
47 SpecializationUtil.registerEventListener(vehicleType, "onDeactivate", Roller)
48 SpecializationUtil.registerEventListener(vehicleType, "onStartWorkAreaProcessing", Roller)
49 SpecializationUtil.registerEventListener(vehicleType, "onEndWorkAreaProcessing", Roller)
50end

registerFunctions

Description
Definition
registerFunctions()
Code
27function Roller.registerFunctions(vehicleType)
28 SpecializationUtil.registerFunction(vehicleType, "processRollerArea", Roller.processRollerArea)
29end

registerOverwrittenFunctions

Description
Definition
registerOverwrittenFunctions()
Code
33function Roller.registerOverwrittenFunctions(vehicleType)
34 SpecializationUtil.registerOverwrittenFunction(vehicleType, "doCheckSpeedLimit", Roller.doCheckSpeedLimit)
35 SpecializationUtil.registerOverwrittenFunction(vehicleType, "getDoGroundManipulation", Roller.getDoGroundManipulation)
36 SpecializationUtil.registerOverwrittenFunction(vehicleType, "getDirtMultiplier", Roller.getDirtMultiplier)
37 SpecializationUtil.registerOverwrittenFunction(vehicleType, "getWearMultiplier", Roller.getWearMultiplier)
38 SpecializationUtil.registerOverwrittenFunction(vehicleType, "getIsWorkAreaActive", Roller.getIsWorkAreaActive)
39end