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
SemiTrailerFront
DescriptionThis is the specialization for semi trailer frontsFunctions
- prerequisitesPresent
- preLoad
- load
- update
- onAttachImplement
- onDetachImplement
- onDetach
- onAttached
- isDetachAllowed
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 SemiTrailerFront.prerequisitesPresent(specializations) |
18 | return SpecializationUtil.hasSpecialization(AttacherJoints, specializations); |
19 | end |
preLoad
DescriptionCalled before loadingDefinition
preLoad(table savegame)Arguments
table | savegame | savegame |
24 | function SemiTrailerFront:preLoad(savegame) |
25 | self.isDetachAllowed = Utils.overwrittenFunction(self.isDetachAllowed, SemiTrailerFront.isDetachAllowed); |
26 | end |
load
DescriptionCalled on loadingDefinition
load(table savegame)Arguments
table | savegame | savegame |
31 | function SemiTrailerFront:load(savegame) |
32 | self.inputAttacherCurFade = 1; |
33 | self.inputAttacherFadeDir = 1; |
34 | self.inputAttacherFadeDuration = 1000; |
35 | |
36 | local joint = self.inputAttacherJoints[1] |
37 | joint.lowerRotLimitScaleBackup = {joint.lowerRotLimitScale[1], joint.lowerRotLimitScale[2], joint.lowerRotLimitScale[3]} |
38 | |
39 | self.attachedSemiTrailerBack = nil; |
40 | self.doSemiTrailerLockCheck = true |
41 | end |
update
DescriptionCalled on updateDefinition
update(float dt)Arguments
float | dt | time since last call in ms |
55 | function SemiTrailerFront:update(dt) |
56 | if self.doSemiTrailerLockCheck then |
57 | self.doSemiTrailerLockCheck = false |
58 | if self.attachedSemiTrailerBack == nil then |
59 | self.inputAttacherFadeDir = -1; |
60 | end |
61 | end |
62 | |
63 | if self.isServer and self.inputAttacherImplement ~= nil and ((self.inputAttacherCurFade > 0 and self.inputAttacherFadeDir < 0) or (self.inputAttacherCurFade < 1 and self.inputAttacherFadeDir > 0)) then |
64 | self.inputAttacherCurFade = Utils.clamp(self.inputAttacherCurFade+(self.inputAttacherFadeDir*dt)/self.inputAttacherFadeDuration, 0, 1) |
65 | self.inputAttacherJoints[1].lowerRotLimitScale[1] = self.inputAttacherJoints[1].lowerRotLimitScaleBackup[1]*self.inputAttacherCurFade |
66 | self.inputAttacherJoints[1].lowerRotLimitScale[2] = self.inputAttacherJoints[1].lowerRotLimitScaleBackup[2]*self.inputAttacherCurFade |
67 | self.inputAttacherJoints[1].lowerRotLimitScale[3] = self.inputAttacherJoints[1].lowerRotLimitScaleBackup[3]*self.inputAttacherCurFade |
68 | |
69 | local jointDesc = self.attacherVehicle.attacherJoints[self.inputAttacherImplement.jointDescIndex] |
70 | local x = self.inputAttacherImplement.lowerRotLimit[1]*self.inputAttacherJoints[1].lowerRotLimitScale[1]; |
71 | local y = self.inputAttacherImplement.lowerRotLimit[2]*self.inputAttacherJoints[1].lowerRotLimitScale[2]; |
72 | local z = self.inputAttacherImplement.lowerRotLimit[3]*self.inputAttacherJoints[1].lowerRotLimitScale[3]; |
73 | |
74 | setJointRotationLimit(jointDesc.jointIndex, 0, true, -x, x); |
75 | setJointRotationLimit(jointDesc.jointIndex, 1, true, -y, y); |
76 | setJointRotationLimit(jointDesc.jointIndex, 2, true, -z, z); |
77 | end |
78 | end |
onAttachImplement
DescriptionCalled on attaching a implementDefinition
onAttachImplement(table implement)Arguments
table | implement | implement to attach |
86 | function SemiTrailerFront:onAttachImplement(implement) |
87 | self.attachedSemiTrailerBack = implement.object; |
88 | self.inputAttacherFadeDir = 1000; |
89 | end |
onDetachImplement
DescriptionCalled on detaching a implementDefinition
onDetachImplement(integer implementIndex)Arguments
integer | implementIndex | index of implement to detach |
94 | function SemiTrailerFront:onDetachImplement(implementIndex) |
95 | self.attachedSemiTrailerBack = nil; |
96 | self.inputAttacherFadeDir = -1; |
97 | end |
onDetach
DescriptionCalled if vehicle gets detachedDefinition
onDetach(table attacherVehicle, integer jointDescIndex)Arguments
table | attacherVehicle | attacher vehicle |
integer | jointDescIndex | index of attacher joint it was attached to |
103 | function SemiTrailerFront:onDetach(attacherVehicle, jointDescIndex) |
104 | self.inputAttacherImplement = nil; |
105 | end |
onAttached
DescriptionCalled after vehicle was attachedDefinition
onAttached(table attacherVehicle, integer jointDescIndex)Arguments
table | attacherVehicle | attacher vehicle |
integer | jointDescIndex | index of attacher joint it was attached to |
111 | function SemiTrailerFront:onAttached(attacherVehicle, implement) |
112 | self.inputAttacherImplement = attacherVehicle:getImplementByObject(self); |
113 | end |
isDetachAllowed
DescriptionReturns true if detach is allowedDefinition
isDetachAllowed()Return Values
boolean | detachAllowed | detach is allowed |
118 | function SemiTrailerFront:isDetachAllowed(superFunc) |
119 | if superFunc ~= nil then |
120 | if not superFunc(self) then |
121 | return false; |
122 | end |
123 | end |
124 | return self.attachedSemiTrailerBack ~= nil; |
125 | end |