Script v1.4.4.0
- Handtools
- Events
- Objects
- Placeables
- Triggers
- Utils
- Vehicles
- Specializations
- AIVehicle
- AnimatedVehicle
- ArticulatedAxis
- Attachable
- AttacherJointControl
- AttacherJoints
- BaleGrab
- BaleLoader
- Baler
- BaleWrapper
- BuiltInCutterTrailer
- BunkerSiloCompacter
- Combine
- ConveyorBelt
- Cover
- CrabSteering
- Crawler
- Cultivator
- Cutter
- Cylindered
- Drivable
- DynamicMountAttacher
- Fillable
- FillActivatable
- FillVolume
- Foldable
- ForageWagon
- FrontloaderAttacher
- FruitPreparer
- FuelTrailer
- Honk
- HookLiftContainer
- HookLiftTrailer
- Leveler
- Lights
- LivestockTrailer
- ManureBarrel
- ManureSpreader
- MixerWagon
- Motorized
- Mountable
- Mower
- NonTabbable
- Overloading
- Pickup
- Pipe
- Plough
- PowerConsumer
- RandomlyMovingParts
- ReceivingHopper
- ReverseDriving
- RidgeMarker
- Roller
- Ropes
- RotorSpreader
- SemiTrailerFront
- Shovel
- SowingMachine
- SpeedRotatingParts
- Sprayer
- Steerable
- StrawBlower
- StumpCutter
- Tedder
- TensionBelts
- Trailer
- TreePlanter
- TreePlanterActivatable
- TreeSaw
- TurnOnVehicle
- Washable
- WaterTrailer
- Weeder
- WheelRotations
- Windrower
- WoodCrusher
- WoodHarvester
- WorkArea
- WorkParticles
Engine v7.0.0.2
- General
- Entity
- Node
- Scenegraph
- Lighting
- Camera
- Shape
- Particle System
- Physics
- Spline
- Animation
- Overlays
- Sound
- Input
- XML
- Network
- Callbacks
- Text Rendering
- Terrain Detail
- Tire Track
- Editor
- Rendering
- String
- Math
- I3D
- Fillplanes
Foundation Reference
BuiltInCutterTrailer
DescriptionClass for cutters with build in cutter trailersFunctions
prerequisitesPresent
DescriptionChecks if all prerequisite specializations are loadedDefinition
prerequisitesPresent(table specializations)Arguments
table | specializations | specializations |
boolean | hasPrerequisite | true if all prerequisite specializations are loaded |
17 | function BuiltInCutterTrailer.prerequisitesPresent(specializations) |
18 | return SpecializationUtil.hasSpecialization(Attachable, specializations) and SpecializationUtil.hasSpecialization(Foldable, specializations); |
19 | end; |
load
DescriptionCalled on loadingDefinition
load(table savegame)Arguments
table | savegame | savegame |
24 | function BuiltInCutterTrailer:load(savegame) |
25 | |
26 | self.getIsFoldAllowed = Utils.overwrittenFunction(self.getIsFoldAllowed, BuiltInCutterTrailer.getIsFoldAllowed); |
27 | self.isDetachAllowed = Utils.overwrittenFunction(self.isDetachAllowed, BuiltInCutterTrailer.isDetachAllowed); |
28 | self.getIsInputAttacherActive = Utils.overwrittenFunction(self.getIsInputAttacherActive, BuiltInCutterTrailer.getIsInputAttacherActive); |
29 | |
30 | local i=0; |
31 | while true do |
32 | local baseName = string.format("vehicle.movingTools.movingTool(%d)", i); |
33 | if not hasXMLProperty(self.xmlFile, baseName) then |
34 | break; |
35 | end; |
36 | |
37 | local node = Utils.indexToObject(self.components, getXMLString(self.xmlFile, baseName.."#index")); |
38 | local disableInTrailerMode = Utils.getNoNil(getXMLBool(self.xmlFile, baseName.."#disableInTrailerMode"), false); |
39 | for _, tool in pairs(self.movingTools) do |
40 | if tool.node == node then |
41 | tool.disableInTrailerMode = disableInTrailerMode; |
42 | break; |
43 | end; |
44 | end; |
45 | i = i + 1; |
46 | end; |
47 | end; |
onAttach
DescriptionCalled if vehicle gets attachedDefinition
onAttach(table attacherVehicle, integer jointDescIndex)Arguments
table | attacherVehicle | attacher vehicle |
integer | jointDescIndex | index of attacher joint it gets attached to |
68 | function BuiltInCutterTrailer:onAttach(attacherVehicle, jointDescIndex) |
69 | local jointDesc = attacherVehicle.attacherJoints[jointDescIndex]; |
70 | if jointDesc.jointType == AttacherJoints.JOINTTYPE_CUTTER then |
71 | for _, tool in pairs(self.movingTools) do |
72 | if tool.disableInTrailerMode then |
73 | tool.isActive = true; |
74 | end; |
75 | end; |
76 | self.attachedAsTrailer = false; |
77 | else |
78 | self:playAnimation("drawbarSetup", -1, nil, true); |
79 | for _, tool in pairs(self.movingTools) do |
80 | if tool.disableInTrailerMode then |
81 | tool.isActive = false; |
82 | end; |
83 | end; |
84 | self.attachedAsTrailer = true; |
85 | end; |
86 | end; |
onDetach
DescriptionCalled if vehicle gets detachedDefinition
onDetach()Code
90 | function BuiltInCutterTrailer:onDetach() |
91 | if self.attachedAsTrailer then |
92 | self:playAnimation("drawbarSetup", 1, nil, true); |
93 | end; |
94 | end; |
getIsInputAttacherActive
DescriptionReturns true if input attacher is active and can be used to attachDefinition
getIsInputAttacherActive(table inputAttacherJoint)Arguments
table | inputAttacherJoint | input attacher joint |
boolean | isActive | input attacher is active |
100 | function BuiltInCutterTrailer:getIsInputAttacherActive(superFunc, inputAttacherJoint) |
101 | if inputAttacherJoint.jointType == AttacherJoints.JOINTTYPE_TRAILERLOW then |
102 | if self.foldAnimTime ~= nil and self.foldAnimTime == 1 then |
103 | return false; |
104 | end; |
105 | end; |
106 | |
107 | if superFunc ~= nil then |
108 | return superFunc(self); |
109 | end |
110 | return true; |
111 | end; |
isDetachAllowed
DescriptionReturns true if detach is allowedDefinition
isDetachAllowed()Return Values
boolean | detachAllowed | detach is allowed |
116 | function BuiltInCutterTrailer:isDetachAllowed(superFunc) |
117 | if self.foldAnimTime ~= nil then |
118 | if self.foldAnimTime > 0 and self.foldAnimTime < 1 then |
119 | return false; |
120 | end; |
121 | end; |
122 | |
123 | if superFunc ~= nil then |
124 | return superFunc(self); |
125 | end |
126 | return true; |
127 | end; |
getIsFoldAllowed
DescriptionReturns if fold is allowedDefinition
getIsFoldAllowed(boolean onAiTurnOn)Arguments
boolean | onAiTurnOn | called on ai turn on |
boolean | allowsFold | allows folding |
133 | function BuiltInCutterTrailer:getIsFoldAllowed(superFunc, onAiTurnOn) |
134 | if self.attacherVehicle ~= nil then |
135 | local implement = self.attacherVehicle:getImplementByObject(self); |
136 | local jointDesc = self.attacherVehicle.attacherJoints[implement.jointDescIndex]; |
137 | if jointDesc.jointType ~= AttacherJoints.JOINTTYPE_CUTTER then |
138 | return false; |
139 | end; |
140 | end; |
141 | |
142 | if superFunc ~= nil then |
143 | return superFunc(self, onAiTurnOn); |
144 | end |
145 | return true; |
146 | end |