LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

WoodCrusher

Description
Specialization for wood crusher allowing to cut and convert tree trunks into wood chips
Functions

crushSplitShape

Description
Crush split shape
Definition
crushSplitShape(integer shape)
Arguments
integershapeid of shape
Code
501function WoodCrusher.crushSplitShape(self, woodCrusher, shape)
502 local splitType = g_splitTypeManager:getSplitTypeByIndex(getSplitType(shape))
503 if splitType ~= nil and splitType.woodChipsPerLiter > 0 then
504 local volume = getVolume(shape)
505 delete(shape)
506 woodCrusher.crushingTime = 1000
507 self:onCrushedSplitShape(splitType, volume)
508 end
509end

deleteWoodCrusher

Description
Delete wood crusher
Definition
deleteWoodCrusher()
Code
323function WoodCrusher.deleteWoodCrusher(self, woodCrusher)
324 if self.isServer and woodCrusher.moveTriggers ~= nil then
325 for _,node in pairs(woodCrusher.moveTriggers) do
326 removeTrigger(node)
327 end
328 end
329
330 if self.isClient then
331 g_effectManager:deleteEffects(woodCrusher.crushEffects)
332 g_soundManager:deleteSamples(woodCrusher.samples)
333 g_animationManager:deleteAnimations(woodCrusher.animationNodes)
334 end
335end

getCanBeTurnedOn

Description
Returns if user is allowed to turn on the vehicle
Definition
getCanBeTurnedOn()
Return Values
booleanallowallow turn on
Code
187function WoodCrusher:getCanBeTurnedOn(superFunc)
188 local spec = self.spec_woodCrusher
189 if spec.turnOnAutomatically then
190 return false
191 end
192
193 return superFunc(self)
194end

getDirtMultiplier

Description
Returns current dirt multiplier
Definition
getDirtMultiplier()
Return Values
floatdirtMultipliercurrent dirt multiplier
Code
199function WoodCrusher:getDirtMultiplier(superFunc)
200 local multiplier = superFunc(self)
201
202 local spec = self.spec_woodCrusher
203 if spec.crushingTime > 0 then
204 multiplier = multiplier + self:getWorkDirtMultiplier()
205 end
206
207 return multiplier
208end

getWearMultiplier

Description
Returns current wear multiplier
Definition
getWearMultiplier()
Return Values
floatdirtMultipliercurrent wear multiplier
Code
213function WoodCrusher:getWearMultiplier(superFunc)
214 local multiplier = superFunc(self)
215
216 local spec = self.spec_woodCrusher
217 if spec.crushingTime > 0 then
218 multiplier = multiplier + self:getWorkWearMultiplier()
219 end
220
221 return multiplier
222end

loadWoodCrusher

Description
Load wood crusher from xml file
Definition
loadWoodCrusher(integer xmlFile, integer rootNode)
Arguments
integerxmlFileid of xml object
integerrootNodeid of root node
Code
237function WoodCrusher.loadWoodCrusher(self, woodCrusher, xmlFile, rootNode)
238 woodCrusher.vehicle = self
239
240 woodCrusher.woodCrusherSplitShapeCallback = WoodCrusher.woodCrusherSplitShapeCallback
241 woodCrusher.woodCrusherMoveTriggerCallback = WoodCrusher.woodCrusherMoveTriggerCallback
242
243 local xmlRoot = getXMLRootName(xmlFile)
244
245 XMLUtil.checkDeprecatedXMLElements(xmlFile, self.configFileName, xmlRoot .. ".woodCrusher.moveTrigger(0)#index", xmlRoot .. ".woodCrusher.moveTriggers.trigger#node") --FS17 to FS19
246 XMLUtil.checkDeprecatedXMLElements(xmlFile, self.configFileName, xmlRoot .. ".woodCrusher.moveCollision(0)#index", xmlRoot .. ".woodCrusher.moveCollisions.collision#node") --FS17 to FS19
247 XMLUtil.checkDeprecatedXMLElements(xmlFile, self.configFileName, xmlRoot .. ".woodCrusher.emitterShape(0)", xmlRoot .. ".woodCrusher.crushEffects with effectClass 'ParticleEffect'") --FS17 to FS19
248 XMLUtil.checkDeprecatedXMLElements(xmlFile, self.configFileName, xmlRoot .. ".woodCrusherStartSound", xmlRoot .. ".woodCrusher.sounds.start") --FS17 to FS19
249 XMLUtil.checkDeprecatedXMLElements(xmlFile, self.configFileName, xmlRoot .. ".woodCrusherIdleSound", xmlRoot .. ".woodCrusher.sounds.idle") --FS17 to FS19
250 XMLUtil.checkDeprecatedXMLElements(xmlFile, self.configFileName, xmlRoot .. ".woodCrusherWorkSound", xmlRoot .. ".woodCrusher.sounds.work") --FS17 to FS19
251 XMLUtil.checkDeprecatedXMLElements(xmlFile, self.configFileName, xmlRoot .. ".woodCrusherStopSound", xmlRoot .. ".woodCrusher.sounds.stop") --FS17 to FS19
252 XMLUtil.checkDeprecatedXMLElements(xmlFile, self.configFileName, xmlRoot .. ".turnedOnRotationNodes.turnedOnRotationNode#type", xmlRoot .. ".woodCrusher.animationNodes.animationNode", "woodCrusher") --FS17 to FS19
253 XMLUtil.checkDeprecatedXMLElements(xmlFile, self.configFileName, xmlRoot .. ".turnedOnScrollers.turnedOnScroller", xmlRoot .. ".woodCrusher.animationNodes.animationNode") --FS17 to FS19
254
255 local baseKey = xmlRoot .. ".woodCrusher"
256 woodCrusher.cutNode = I3DUtil.indexToObject(rootNode, getXMLString(xmlFile, baseKey.."#cutNode"), self.i3dMappings)
257 woodCrusher.mainDrumRefNode = I3DUtil.indexToObject(rootNode, getXMLString(xmlFile, baseKey.."#mainDrumRefNode"), self.i3dMappings)
258
259 woodCrusher.moveTriggers = {}
260 local i = 0
261 while true do
262 local key = string.format("%s.moveTriggers.trigger(%d)", baseKey, i)
263 if not hasXMLProperty(xmlFile, key) then
264 break
265 end
266
267 local node = I3DUtil.indexToObject(rootNode, getXMLString(xmlFile, key .. "#node"), self.i3dMappings)
268 if node ~= nil then
269 table.insert(woodCrusher.moveTriggers, node)
270 end
271 i = i + 1
272 end
273
274 woodCrusher.moveColNodes = {}
275 i = 0
276 while true do
277 local key = string.format("%s.moveCollisions.collision(%d)", baseKey, i)
278 if not hasXMLProperty(xmlFile, key) then
279 break
280 end
281
282 local node = I3DUtil.indexToObject(rootNode, getXMLString(xmlFile, key .. "#node"), self.i3dMappings)
283 if node ~= nil then
284 table.insert(woodCrusher.moveColNodes, node)
285 end
286 i = i + 1
287 end
288
289 woodCrusher.moveVelocityZ = Utils.getNoNil(getXMLFloat(xmlFile, baseKey.."#moveVelocityZ"), 0.8) -- m/s
290 woodCrusher.moveMaxForce = Utils.getNoNil(getXMLFloat(xmlFile, baseKey.."#moveMaxForce"), 7) -- input is kN
291 woodCrusher.downForceNode = I3DUtil.indexToObject(rootNode, getXMLString(xmlFile, baseKey.."#downForceNode"), self.i3dMappings)
292 woodCrusher.downForce = Utils.getNoNil(getXMLFloat(xmlFile, baseKey.."#downForce"), 2)
293 woodCrusher.cutSizeY = Utils.getNoNil(getXMLFloat(xmlFile, baseKey.."#cutSizeY"), 1)
294 woodCrusher.cutSizeZ = Utils.getNoNil(getXMLFloat(xmlFile, baseKey.."#cutSizeZ"), 1)
295
296 woodCrusher.moveTriggerNodes = {}
297 if self.isServer and woodCrusher.moveTriggers ~= nil then
298 for _,node in pairs(woodCrusher.moveTriggers) do
299 addTrigger(node, "woodCrusherMoveTriggerCallback", woodCrusher)
300 end
301 end
302
303 woodCrusher.crushNodes = {}
304 woodCrusher.crushingTime = 0
305 woodCrusher.turnOnAutomatically = Utils.getNoNil(getXMLBool(xmlFile, baseKey .. "#automaticallyTurnOn"), false)
306
307 if self.isClient then
308 woodCrusher.crushEffects = g_effectManager:loadEffect(xmlFile, baseKey..".crushEffects", rootNode, self, self.i3dMappings)
309
310 woodCrusher.animationNodes = g_animationManager:loadAnimations(xmlFile, baseKey..".animationNodes", rootNode, self, self.i3dMappings)
311
312 woodCrusher.isWorkSamplePlaying = false
313 woodCrusher.samples = {}
314 woodCrusher.samples.start = g_soundManager:loadSampleFromXML(xmlFile, baseKey..".sounds", "start", self.baseDirectory, rootNode, 1, AudioGroup.VEHICLE, self.i3dMappings, self)
315 woodCrusher.samples.stop = g_soundManager:loadSampleFromXML(xmlFile, baseKey..".sounds", "stop", self.baseDirectory, rootNode, 1, AudioGroup.VEHICLE, self.i3dMappings, self)
316 woodCrusher.samples.work = g_soundManager:loadSampleFromXML(xmlFile, baseKey..".sounds", "work", self.baseDirectory, rootNode, 0, AudioGroup.VEHICLE, self.i3dMappings, self)
317 woodCrusher.samples.idle = g_soundManager:loadSampleFromXML(xmlFile, baseKey..".sounds", "idle", self.baseDirectory, rootNode, 0, AudioGroup.VEHICLE, self.i3dMappings, self)
318 end
319end

onCrushedSplitShape

Description
Called on crush split shape
Definition
onCrushedSplitShape(table splitType, float volume)
Arguments
tablesplitTypesplit type
floatvolumevolume
Code
228function WoodCrusher:onCrushedSplitShape(splitType, volume)
229 local spec = self.spec_woodCrusher
230 self:addFillUnitFillLevel(self:getOwnerFarmId(), spec.fillUnitIndex, volume * 1000 * splitType.woodChipsPerLiter, FillType.WOODCHIPS, ToolType.UNDEFINED)
231end

onDelete

Description
Called on deleting
Definition
onDelete()
Code
70function WoodCrusher:onDelete()
71 WoodCrusher.deleteWoodCrusher(self, self.spec_woodCrusher)
72end

onLoad

Description
Called on loading
Definition
onLoad(table savegame)
Arguments
tablesavegamesavegame
Code
51function WoodCrusher:onLoad(savegame)
52 local spec = self.spec_woodCrusher
53
54 WoodCrusher.loadWoodCrusher(self, spec, self.xmlFile, self.components)
55
56 local moveColDisableCollisionPairs = Utils.getNoNil(getXMLBool(self.xmlFile, "vehicle.woodCrusher#moveColDisableCollisionPairs"), true)
57 if moveColDisableCollisionPairs then
58 for _, component in pairs(self.components) do
59 for _, node in pairs(spec.moveColNodes) do
60 setPairCollision(component.node, node, false)
61 end
62 end
63 end
64
65 spec.fillUnitIndex = Utils.getNoNil(getXMLInt(self.xmlFile, "vehicle.woodCrusher#fillUnitIndex"), 1)
66end

onReadUpdateStream

Description
Called on on update
Definition
onReadUpdateStream(integer streamId, integer timestamp, table connection)
Arguments
integerstreamIdstream ID
integertimestamptimestamp
tableconnectionconnection
Code
79function WoodCrusher:onReadUpdateStream(streamId, timestamp, connection)
80 if connection:getIsServer() then
81 local spec = self.spec_woodCrusher
82 if streamReadBool(streamId) then
83 spec.crushingTime = 1000
84 else
85 spec.crushingTime = 0
86 end
87 end
88end

onTurnedOff

Description
Called on turn off
Definition
onTurnedOff(boolean noEventSend)
Arguments
booleannoEventSendno event send
Code
180function WoodCrusher:onTurnedOff()
181 WoodCrusher.turnOffWoodCrusher(self, self.spec_woodCrusher)
182end

onTurnedOn

Description
Called on turn on
Definition
onTurnedOn(boolean noEventSend)
Arguments
booleannoEventSendno event send
Code
173function WoodCrusher:onTurnedOn()
174 WoodCrusher.turnOnWoodCrusher(self, self.spec_woodCrusher)
175end

onUpdate

Description
Called on update
Definition
onUpdate(float dt, boolean isActiveForInput, boolean isSelected)
Arguments
floatdttime since last call in ms
booleanisActiveForInputtrue if vehicle is active for input
booleanisSelectedtrue if vehicle is selected
Code
107function WoodCrusher:onUpdate(dt, isActiveForInput, isActiveForInputIgnoreSelection, isSelected)
108 WoodCrusher.updateWoodCrusher(self, self.spec_woodCrusher, dt, self:getIsTurnedOn())
109end

onUpdateTick

Description
Called on update tick
Definition
onUpdateTick(float dt, boolean isActiveForInput, boolean isSelected)
Arguments
floatdttime since last call in ms
booleanisActiveForInputtrue if vehicle is active for input
booleanisSelectedtrue if vehicle is selected
Code
116function WoodCrusher:onUpdateTick(dt, isActiveForInput, isActiveForInputIgnoreSelection, isSelected)
117 WoodCrusher.updateTickWoodCrusher(self, self.spec_woodCrusher, dt, self:getIsTurnedOn())
118
119 local spec = self.spec_woodCrusher
120 -- turn on/off automatically if tree node is in trigger
121 if self.isServer then
122 if g_currentMission.missionInfo.automaticMotorStartEnabled then
123 if spec.turnOnAutomatically and self.setIsTurnedOn ~= nil then
124 if next(spec.moveTriggerNodes) ~= nil then
125 if self.getIsMotorStarted ~= nil then
126 if not self:getIsMotorStarted() then
127 self:startMotor()
128 end
129 else
130 if self.attacherVehicle ~= nil then
131 if self.attacherVehicle.getIsMotorStarted ~= nil then
132 if not self.attacherVehicle:getIsMotorStarted() then
133 self.attacherVehicle:startMotor()
134 end
135 end
136 end
137 end
138
139 if not self.isControlled and not self:getIsTurnedOn() and self:getCanBeTurnedOn() then
140 self:setIsTurnedOn(true)
141 end
142 spec.turnOffTimer = 3000
143 else
144 if self:getIsTurnedOn() then
145 if spec.turnOffTimer == nil then
146 spec.turnOffTimer = 3000
147 end
148 spec.turnOffTimer = spec.turnOffTimer - dt
149
150 if spec.turnOffTimer < 0 then
151 local rootAttacherVehicle = self:getRootVehicle()
152
153 if not rootAttacherVehicle.isControlled then
154 if self.getIsMotorStarted ~= nil then
155 if self:getIsMotorStarted() then
156 self:stopMotor()
157 end
158 end
159
160 self:setIsTurnedOn(false)
161 end
162 end
163 end
164 end
165 end
166 end
167 end
168end

onWriteUpdateStream

Description
Called on on update
Definition
onWriteUpdateStream(integer streamId, table connection, integer dirtyMask)
Arguments
integerstreamIdstream ID
tableconnectionconnection
integerdirtyMaskdirty mask
Code
95function WoodCrusher:onWriteUpdateStream(streamId, connection, dirtyMask)
96 if not connection:getIsServer() then
97 local spec = self.spec_woodCrusher
98 streamWriteBool(streamId, spec.crushingTime > 0)
99 end
100end

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 WoodCrusher.prerequisitesPresent(specializations)
18 return SpecializationUtil.hasSpecialization(TurnOnVehicle, specializations) and SpecializationUtil.hasSpecialization(FillUnit, specializations)
19end

registerEventListeners

Description
Definition
registerEventListeners()
Code
37function WoodCrusher.registerEventListeners(vehicleType)
38 SpecializationUtil.registerEventListener(vehicleType, "onLoad", WoodCrusher)
39 SpecializationUtil.registerEventListener(vehicleType, "onDelete", WoodCrusher)
40 SpecializationUtil.registerEventListener(vehicleType, "onReadUpdateStream", WoodCrusher)
41 SpecializationUtil.registerEventListener(vehicleType, "onWriteUpdateStream", WoodCrusher)
42 SpecializationUtil.registerEventListener(vehicleType, "onUpdate", WoodCrusher)
43 SpecializationUtil.registerEventListener(vehicleType, "onUpdateTick", WoodCrusher)
44 SpecializationUtil.registerEventListener(vehicleType, "onTurnedOn", WoodCrusher)
45 SpecializationUtil.registerEventListener(vehicleType, "onTurnedOff", WoodCrusher)
46end

registerFunctions

Description
Definition
registerFunctions()
Code
23function WoodCrusher.registerFunctions(vehicleType)
24 SpecializationUtil.registerFunction(vehicleType, "onCrushedSplitShape", WoodCrusher.onCrushedSplitShape)
25end

registerOverwrittenFunctions

Description
Definition
registerOverwrittenFunctions()
Code
29function WoodCrusher.registerOverwrittenFunctions(vehicleType)
30 SpecializationUtil.registerOverwrittenFunction(vehicleType, "getDirtMultiplier", WoodCrusher.getDirtMultiplier)
31 SpecializationUtil.registerOverwrittenFunction(vehicleType, "getWearMultiplier", WoodCrusher.getWearMultiplier)
32 SpecializationUtil.registerOverwrittenFunction(vehicleType, "getCanBeTurnedOn", WoodCrusher.getCanBeTurnedOn)
33end

turnOffWoodCrusher

Description
Turn off wood crusher
Definition
turnOffWoodCrusher()
Code
473function WoodCrusher.turnOffWoodCrusher(self, woodCrusher)
474 if self.isServer then
475 for node in pairs(woodCrusher.crushNodes) do
476 WoodCrusher.crushSplitShape(self, woodCrusher, node)
477 woodCrusher.crushNodes[node] = nil
478 end
479 if woodCrusher.moveColNodes ~= nil then
480 for _,node in pairs(woodCrusher.moveColNodes) do
481 setFrictionVelocity(node, 0.0)
482 end
483 end
484 end
485
486 if self.isClient then
487 g_effectManager:stopEffects(woodCrusher.crushEffects)
488 g_soundManager:stopSamples(woodCrusher.samples)
489 g_soundManager:playSample(woodCrusher.samples.stop)
490 woodCrusher.isWorkSamplePlaying = false
491
492 if self.isClient then
493 g_animationManager:stopAnimations(woodCrusher.animationNodes)
494 end
495 end
496end

turnOnWoodCrusher

Description
Turn on wood crusher
Definition
turnOnWoodCrusher()
Code
452function WoodCrusher.turnOnWoodCrusher(self, woodCrusher)
453 if self.isServer and woodCrusher.moveColNodes ~= nil then
454 for _,node in pairs(woodCrusher.moveColNodes) do
455 setFrictionVelocity(node, woodCrusher.moveVelocityZ)
456 end
457 end
458
459 if self.isClient then
460 g_soundManager:stopSamples(woodCrusher.samples)
461 woodCrusher.isWorkSamplePlaying = false
462 g_soundManager:playSample(woodCrusher.samples.start)
463 g_soundManager:playSample(woodCrusher.samples.idle, 0, woodCrusher.samples.start)
464
465 if self.isClient then
466 g_animationManager:startAnimations(woodCrusher.animationNodes)
467 end
468 end
469end

updateTickWoodCrusher

Description
Update tick wood crusher
Definition
updateTickWoodCrusher(float dt)
Arguments
floatdttime since last call in ms
Code
397function WoodCrusher.updateTickWoodCrusher(self, woodCrusher, dt, isTurnedOn)
398 if isTurnedOn then
399 if self.isServer then
400 if woodCrusher.cutNode ~= nil and next(woodCrusher.moveTriggerNodes) ~= nil then
401 local x,y,z = getWorldTranslation(woodCrusher.cutNode)
402 local nx,ny,nz = localDirectionToWorld(woodCrusher.cutNode, 1,0,0)
403 local yx,yy,yz = localDirectionToWorld(woodCrusher.cutNode, 0,1,0)
404 for id in pairs(woodCrusher.moveTriggerNodes) do
405 local lenBelow, lenAbove = getSplitShapePlaneExtents(id, x,y,z, nx,ny,nz)
406 if lenAbove ~= nil and lenBelow ~= nil then
407 if lenBelow <= 0.4 then
408 woodCrusher.moveTriggerNodes[id] = nil
409 WoodCrusher.crushSplitShape(self, woodCrusher, id)
410 elseif lenAbove >= 0.2 then
411 local minY = splitShape(id, x,y,z, nx,ny,nz, yx,yy,yz, woodCrusher.cutSizeY, woodCrusher.cutSizeZ, "woodCrusherSplitShapeCallback", woodCrusher)
412 if minY ~= nil then
413 woodCrusher.moveTriggerNodes[id] = nil
414 end
415 end
416 end
417 end
418 end
419 end
420 end
421
422 if woodCrusher.crushingTime > 0 then
423 woodCrusher.crushingTime = math.max(woodCrusher.crushingTime - dt, 0)
424 end
425
426 local isCrushing = woodCrusher.crushingTime > 0
427
428 if self.isClient then
429 if isCrushing then
430 g_effectManager:setFillType(woodCrusher.crushEffects, FillType.WOODCHIPS)
431 g_effectManager:startEffects(woodCrusher.crushEffects)
432 else
433 g_effectManager:stopEffects(woodCrusher.crushEffects)
434 end
435
436 if isTurnedOn and isCrushing then
437 if not woodCrusher.isWorkSamplePlaying then
438 g_soundManager:playSample(woodCrusher.samples.work)
439 woodCrusher.isWorkSamplePlaying = true
440 end
441 else
442 if woodCrusher.isWorkSamplePlaying then
443 g_soundManager:stopSample(woodCrusher.samples.work)
444 woodCrusher.isWorkSamplePlaying = false
445 end
446 end
447 end
448end

updateWoodCrusher

Description
Update wood crusher
Definition
updateWoodCrusher(float dt)
Arguments
floatdttime since last call in ms
Code
340function WoodCrusher.updateWoodCrusher(self, woodCrusher, dt, isTurnedOn)
341 if isTurnedOn then
342 if self.isServer then
343 for node in pairs(woodCrusher.crushNodes) do
344 WoodCrusher.crushSplitShape(self, woodCrusher, node)
345 woodCrusher.crushNodes[node] = nil
346 woodCrusher.moveTriggerNodes[node] = nil
347 end
348
349 local x,y,z = getTranslation(woodCrusher.mainDrumRefNode)
350 local _, ty, _ = 0, 0, 0
351 local maxTreeSizeY = 0
352 for id in pairs(woodCrusher.moveTriggerNodes) do
353 if not entityExists(id) then
354 woodCrusher.moveTriggerNodes[id] = nil
355 else
356 if woodCrusher.downForceNode ~= nil then
357 local x,y,z = getWorldTranslation(woodCrusher.downForceNode)
358 local nx,ny,nz = localDirectionToWorld(woodCrusher.downForceNode, 1,0,0)
359 local yx,yy,yz = localDirectionToWorld(woodCrusher.downForceNode, 0,1,0)
360
361 local minY,maxY, minZ,maxZ = testSplitShape(id, x,y,z, nx,ny,nz, yx,yy,yz, woodCrusher.cutSizeY, woodCrusher.cutSizeZ)
362 if minY ~= nil then
363 local cx,cy,cz = localToWorld(woodCrusher.downForceNode, 0, (minY+maxY)*0.5, (minZ+maxZ)*0.5)
364 local downX,downY,downZ = localDirectionToWorld(woodCrusher.downForceNode, 0,-woodCrusher.downForce,0)
365 addForce(id, downX, downY, downZ, cx,cy,cz, false)
366 if woodCrusher.mainDrumRefNode ~= nil then
367 maxTreeSizeY = math.max(maxTreeSizeY, maxY)
368 end
369 end
370
371 end
372 end
373 end
374 if woodCrusher.mainDrumRefNode ~= nil then
375 if maxTreeSizeY > 0 then
376 local a,b,c = localToWorld(woodCrusher.downForceNode, 0, maxTreeSizeY, 0)
377 _, ty, _ = worldToLocal(getParent(woodCrusher.mainDrumRefNode), a,b,c)
378 end
379 if ty > y then
380 y = math.min(y + 0.0003*dt, ty)
381 else
382 y = math.max(y - 0.0003*dt, ty)
383 end
384 setTranslation(woodCrusher.mainDrumRefNode, x,y,z)
385 end
386
387 if next(woodCrusher.moveTriggerNodes) ~= nil or woodCrusher.crushingTime > 0 then
388 self:raiseActive()
389 end
390 end
391 end
392end

woodCrusherMoveTriggerCallback

Description
Trigger callback
Definition
woodCrusherMoveTriggerCallback(integer triggerId, integer otherActorId, boolean onEnter, boolean onLeave, boolean onStay, integer otherShapeId)
Arguments
integertriggerIdid of trigger
integerotherActorIdid of other actor
booleanonEnteron enter
booleanonLeaveon leave
booleanonStayon stay
integerotherShapeIdid of other shape
Code
534function WoodCrusher.woodCrusherMoveTriggerCallback(self, triggerId, otherActorId, onEnter, onLeave, onStay, otherShapeId)
535 local vehicle = g_currentMission.nodeToObject[otherActorId]
536 if vehicle == nil and getRigidBodyType(otherActorId) == "Dynamic" then
537 local splitType = g_splitTypeManager:getSplitTypeByIndex(getSplitType(otherActorId))
538 if splitType ~= nil and splitType.woodChipsPerLiter > 0 then
539 if onEnter then
540 self.moveTriggerNodes[otherActorId] = Utils.getNoNil(self.moveTriggerNodes[otherActorId],0)+1
541 self.vehicle:raiseActive()
542 elseif onLeave then
543 local c = self.moveTriggerNodes[otherActorId]
544 if c ~= nil then
545 c = c-1
546 if c == 0 then
547 self.moveTriggerNodes[otherActorId] = nil
548 else
549 self.moveTriggerNodes[otherActorId] = c
550 end
551 end
552 end
553 end
554 end
555end

woodCrusherSplitShapeCallback

Description
Split shape callback
Definition
woodCrusherSplitShapeCallback(integer shape, boolean isBelow, boolean isAbove, float minY, float maxY, float minZ, float maxZ)
Arguments
integershapeshape
booleanisBelowis below
booleanisAboveis above
floatminYmin y split position
floatmaxYmax y split position
floatminZmin z split position
floatmaxZmax z split position
Code
520function WoodCrusher.woodCrusherSplitShapeCallback(self, shape, isBelow, isAbove, minY, maxY, minZ, maxZ)
521 if not isBelow then
522 self.crushNodes[shape] = shape
523 end
524end