Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- AIConveyorBelt
- AIDrivable
- AIFieldWorker
- AIImplement
- AIJobVehicle
- AIVehicle
- AIVehicleObstacle
- AnimatedVehicle
- ArticulatedAxis
- Attachable
- AttacherJointControl
- AttacherJoints
- AutoLoader
- BaleGrab
- BaleLoader
- Baler
- BaleWrapper
- BaseMaterial
- BigBag
- BunkerSiloCompacter
- BunkerSiloInteractor
- CCTDrivable
- Combine
- ConnectionHoses
- ConveyorBelt
- Cover
- CrabSteering
- Crawlers
- CropSensor
- Cultivator
- Cutter
- Cylindered
- CylinderedFoldable
- Dashboard
- Dischargeable
- Drivable
- DynamicallyLoadedParts
- DynamicMountAttacher
- Enterable
- ExtendedAIVehicle
- ExtendedCombine
- ExtendedMotorized
- ExtendedMower
- ExtendedSowingMachine
- ExtendedSprayer
- ExtendedWearable
- FertilizingCultivator
- FertilizingSowingMachine
- FillTriggerVehicle
- FillUnit
- FillVolume
- Foldable
- FoliageBending
- ForageWagon
- FrontloaderAttacher
- FruitPreparer
- GroundAdjustedNodes
- GroundReference
- HeadlandAnimation
- Honk
- HookLiftContainer
- HookLiftTrailer
- IKChains
- InlineWrapper
- JigglingParts
- Leveler
- LicensePlates
- Lights
- LivestockTrailer
- Locomotive
- LogGrab
- ManureBarrel
- ManureSensor
- MixerWagon
- Motorized
- Mountable
- Mower
- Mulcher
- MultipleItemPurchase
- Pallet
- Pickup
- Pipe
- PlaceableAI
- PlaceableAnimatedObjects
- PlaceableBeehive
- PlaceableBeehivePalletSpa...
- PlaceableBunkerSilo
- PlaceableBuyingStation
- PlaceableCartridgePlayer
- PlaceableChargingStation
- PlaceableClearAreas
- PlaceableColorable
- PlaceableDeletedNodes
- PlaceableDoghouse
- PlaceableDynamicallyLoade...
- PlaceableFarmhouse
- PlaceableFence
- PlaceableFoliageAreas
- PlaceableGreenhouse
- PlaceableHighPressureWash...
- PlaceableHotspots
- PlaceableHusbandry
- PlaceableHusbandryAnimals
- PlaceableHusbandryFeeding...
- PlaceableHusbandryFence
- PlaceableHusbandryFood
- PlaceableHusbandryLiquidM...
- PlaceableHusbandryMilk
- PlaceableHusbandryPallets
- PlaceableHusbandryStraw
- PlaceableHusbandryWater
- PlaceableIncomePerHour
- PlaceableIndoorAreas
- PlaceableInfoTrigger
- PlaceableLeveling
- PlaceableLights
- PlaceableManureHeap
- PlaceablePlacement
- PlaceableProductionPoint
- PlaceableSellingStation
- PlaceableSilo
- PlaceableSiloExtension
- PlaceableSolarPanels
- PlaceableTipOcclusionArea...
- PlaceableTrainSystem
- PlaceableTriggerMarkers
- PlaceableVine
- PlaceableWardrobe
- PlaceableWeatherStation
- PlaceableWeighingStation
- PlaceableWindTurbine
- PlaceableWorkshop
- Plow
- PlowPacker
- PowerConsumer
- PowerTakeOffs
- PrecisionFarmingStatistic
- PushHandTool
- RandomlyMovingParts
- ReceivingHopper
- ReverseDriving
- Rideable
- RidgeMarker
- Roller
- Ropes
- RTKStation
- SaltSpreader
- SemiTrailerFront
- Shovel
- SlopeCompensation
- SmartAttach
- SoilSampler
- SowingMachine
- SpeedRotatingParts
- SplineVehicle
- Sprayer
- StonePicker
- StrawBlower
- StumpCutter
- SupportVehicle
- Suspensions
- Tedder
- TensionBeltObject
- TensionBelts
- TestAreas
- TipOccluder
- Trailer
- TreePlanter
- TreeSaplingPallet
- TreeSaw
- TurnOnVehicle
- VariableWorkWidth
- VehicleSettings
- VineCutter
- VineDetector
- VinePrepruner
- Washable
- WaterTrailer
- Wearable
- Weeder
- WeedSpotSpray
- Wheels
- WindBending
- Windrower
- Wipers
- WoodCrusher
- WoodHarvester
- WorkArea
- WorkMode
- WorkParticles
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
HookLiftTrailer
DescriptionSpecialization for hooklift trailers providing separate load-up and tipping animationsFunctions
- getCanDetachContainer
- getDoConsumePtoPower
- getIsFoldAllowed
- getIsTippingAllowed
- getPtoRpm
- initSpecialization
- isDetachAllowed
- onLoad
- onPostAttachImplement
- onPostLoad
- onPreDetachImplement
- onUpdateTick
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerOverwrittenFunctions
- startTipping
- stopTipping
getCanDetachContainer
DescriptionDefinitiongetCanDetachContainer()Code
207 | function HookLiftTrailer:getCanDetachContainer() |
208 | local spec = self.spec_hookLiftTrailer |
209 | return self:getAnimationTime(spec.refAnimation) == 1 |
210 | end |
getDoConsumePtoPower
DescriptionReturns if should consume pto powerDefinition
getDoConsumePtoPower()Return Values
boolean | consume | consumePtoPower |
238 | function HookLiftTrailer:getDoConsumePtoPower(superFunc) |
239 | local spec = self.spec_hookLiftTrailer |
240 | local doConsume = superFunc(self) |
241 | |
242 | return doConsume or self:getIsAnimationPlaying(spec.refAnimation) or self:getIsAnimationPlaying(spec.unloadingAnimation) |
243 | end |
getIsFoldAllowed
DescriptionReturns if fold is allowedDefinition
getIsFoldAllowed()Return Values
boolean | allowsFold | allows folding |
215 | function HookLiftTrailer:getIsFoldAllowed(superFunc, direction, onAiTurnOn) |
216 | local spec = self.spec_hookLiftTrailer |
217 | if self:getAnimationTime(spec.unloadingAnimation) > 0 then |
218 | return false |
219 | end |
220 | |
221 | return superFunc(self, direction, onAiTurnOn) |
222 | end |
getIsTippingAllowed
DescriptionReturns if tipping is allowedDefinition
getIsTippingAllowed()Return Values
boolean | tippingAllowed | tipping is allowed |
200 | function HookLiftTrailer:getIsTippingAllowed() |
201 | local spec = self.spec_hookLiftTrailer |
202 | return self:getAnimationTime(spec.refAnimation) == 0 |
203 | end |
getPtoRpm
DescriptionReturns rpm of ptoDefinition
getPtoRpm()Return Values
float | rpm | rpm of pto |
248 | function HookLiftTrailer:getPtoRpm(superFunc) |
249 | local spec = self.spec_hookLiftTrailer |
250 | local rpm = superFunc(self) |
251 | |
252 | if self:getIsAnimationPlaying(spec.refAnimation) or self:getIsAnimationPlaying(spec.unloadingAnimation) then |
253 | return self.spec_powerConsumer.ptoRpm |
254 | else |
255 | return rpm |
256 | end |
257 | end |
initSpecialization
DescriptionCalled on specialization initializingDefinition
initSpecialization()Code
23 | function HookLiftTrailer.initSpecialization() |
24 | local schema = Vehicle.xmlSchema |
25 | schema:setXMLSpecializationType("HookLiftTrailer") |
26 | |
27 | schema:register(XMLValueType.FLOAT, "vehicle.hookLiftTrailer.jointLimits.key(?)#time", "Key time") |
28 | schema:register(XMLValueType.VECTOR_ROT, "vehicle.hookLiftTrailer.jointLimits.key(?)#rotLimit", "Rotation limit", "0 0 0") |
29 | schema:register(XMLValueType.VECTOR_TRANS, "vehicle.hookLiftTrailer.jointLimits.key(?)#transLimit", "Translation limit", "0 0 0") |
30 | |
31 | schema:register(XMLValueType.STRING, "vehicle.hookLiftTrailer.jointLimits#refAnimation", "Reference animation", "unfoldHand") |
32 | schema:register(XMLValueType.STRING, "vehicle.hookLiftTrailer.unloadingAnimation#name", "Unload animation", "unloading") |
33 | schema:register(XMLValueType.FLOAT, "vehicle.hookLiftTrailer.unloadingAnimation#speed", "Unload animation speed", 1) |
34 | schema:register(XMLValueType.FLOAT, "vehicle.hookLiftTrailer.unloadingAnimation#reverseSpeed", "Unload animation reverse speed", -1) |
35 | |
36 | schema:register(XMLValueType.STRING, "vehicle.hookLiftTrailer.texts#unloadContainer", "Unload container text", "unload_container") |
37 | schema:register(XMLValueType.STRING, "vehicle.hookLiftTrailer.texts#loadContainer", "Load container text", "load_container") |
38 | schema:register(XMLValueType.STRING, "vehicle.hookLiftTrailer.texts#unloadArm", "Unload arm text", "unload_arm") |
39 | schema:register(XMLValueType.STRING, "vehicle.hookLiftTrailer.texts#loadArm", "Load arm text", "load_arm") |
40 | |
41 | schema:setXMLSpecializationType() |
42 | end |
isDetachAllowed
DescriptionReturns true if detach is allowedDefinition
isDetachAllowed()Return Values
boolean | detachAllowed | detach is allowed |
227 | function HookLiftTrailer:isDetachAllowed(superFunc) |
228 | if self:getAnimationTime(self.spec_hookLiftTrailer.unloadingAnimation) == 0 then |
229 | return superFunc(self) |
230 | else |
231 | return false, nil |
232 | end |
233 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
75 | function HookLiftTrailer:onLoad(savegame) |
76 | local spec = self.spec_hookLiftTrailer |
77 | |
78 | spec.jointLimits = AnimCurve.new(linearInterpolatorN) |
79 | local i = 0 |
80 | while true do |
81 | local key = string.format("vehicle.hookLiftTrailer.jointLimits.key(%d)", i) |
82 | if not self.xmlFile:hasProperty(key) then |
83 | if i == 0 then |
84 | spec.jointLimits = nil |
85 | end |
86 | break |
87 | end |
88 | |
89 | local t = self.xmlFile:getValue(key.."#time") |
90 | local rx, ry, rz = self.xmlFile:getValue(key.."#rotLimit", "0 0 0") |
91 | local tx, ty, tz = self.xmlFile:getValue(key.."#transLimit", "0 0 0") |
92 | spec.jointLimits:addKeyframe({rx, ry, rz, tx, ty, tz, time = t}) |
93 | |
94 | i = i + 1 |
95 | end |
96 | |
97 | spec.refAnimation = self.xmlFile:getValue("vehicle.hookLiftTrailer.jointLimits#refAnimation", "unfoldHand") |
98 | spec.unloadingAnimation = self.xmlFile:getValue("vehicle.hookLiftTrailer.unloadingAnimation#name", "unloading") |
99 | spec.unloadingAnimationSpeed = self.xmlFile:getValue("vehicle.hookLiftTrailer.unloadingAnimation#speed", 1) |
100 | spec.unloadingAnimationReverseSpeed = self.xmlFile:getValue("vehicle.hookLiftTrailer.unloadingAnimation#reverseSpeed", -1) |
101 | |
102 | spec.texts = {} |
103 | spec.texts.unloadContainer = g_i18n:getText(self.xmlFile:getValue("vehicle.hookLiftTrailer.texts#unloadContainer", "unload_container"), self.customEnvironment) |
104 | spec.texts.loadContainer = g_i18n:getText(self.xmlFile:getValue("vehicle.hookLiftTrailer.texts#loadContainer", "load_container"), self.customEnvironment) |
105 | spec.texts.unloadArm = g_i18n:getText(self.xmlFile:getValue("vehicle.hookLiftTrailer.texts#unloadArm", "unload_arm"), self.customEnvironment) |
106 | spec.texts.loadArm = g_i18n:getText(self.xmlFile:getValue("vehicle.hookLiftTrailer.texts#loadArm", "load_arm"), self.customEnvironment) |
107 | end |
onPostAttachImplement
DescriptionCalled on attaching a implementDefinition
onPostAttachImplement(table implement)Arguments
table | implement | implement to attach |
148 | function HookLiftTrailer:onPostAttachImplement(attachable, inputJointDescIndex, jointDescIndex) |
149 | local spec = self.spec_hookLiftTrailer |
150 | |
151 | local attacherJoint = attachable:getActiveInputAttacherJoint() |
152 | if attacherJoint ~= nil then |
153 | if attacherJoint.jointType == AttacherJoints.JOINTTYPE_HOOKLIFT then |
154 | local jointDesc = self:getAttacherJointByJointDescIndex(jointDescIndex) |
155 | spec.attachedContainer = {} |
156 | spec.attachedContainer.jointIndex = jointDesc.jointIndex |
157 | spec.attachedContainer.implement = self:getImplementByObject(attachable) |
158 | spec.attachedContainer.object = attachable |
159 | spec.attachedContainer.limitLocked = false |
160 | |
161 | local foldableSpec = self.spec_foldable |
162 | foldableSpec.posDirectionText = spec.texts.unloadContainer |
163 | foldableSpec.negDirectionText = spec.texts.loadContainer |
164 | end |
165 | end |
166 | end |
onPostLoad
DescriptionCalled after loadingDefinition
onPostLoad(table savegame)Arguments
table | savegame | savegame |
112 | function HookLiftTrailer:onPostLoad(savegame) |
113 | local spec = self.spec_hookLiftTrailer |
114 | local foldableSpec = self.spec_foldable |
115 | foldableSpec.posDirectionText = spec.texts.unloadArm |
116 | foldableSpec.negDirectionText = spec.texts.loadArm |
117 | end |
onPreDetachImplement
DescriptionCalled on detaching a implementDefinition
onPreDetachImplement(integer implementIndex)Arguments
integer | implementIndex | index of implement to detach |
171 | function HookLiftTrailer:onPreDetachImplement(implement) |
172 | local spec = self.spec_hookLiftTrailer |
173 | if spec.attachedContainer ~= nil then |
174 | if implement == spec.attachedContainer.implement then |
175 | local foldableSpec = self.spec_foldable |
176 | foldableSpec.posDirectionText = spec.texts.unloadArm |
177 | foldableSpec.negDirectionText = spec.texts.loadArm |
178 | spec.attachedContainer = nil |
179 | end |
180 | end |
181 | end |
onUpdateTick
DescriptionCalled on update tickDefinition
onUpdateTick(float dt, boolean isActiveForInput, boolean isSelected)Arguments
float | dt | time since last call in ms |
boolean | isActiveForInput | true if vehicle is active for input |
boolean | isSelected | true if vehicle is selected |
124 | function HookLiftTrailer:onUpdateTick(dt, isActiveForInput, isActiveForInputIgnoreSelection, isSelected) |
125 | local spec = self.spec_hookLiftTrailer |
126 | |
127 | if spec.attachedContainer ~= nil then |
128 | local animTime = self:getAnimationTime(spec.refAnimation) |
129 | spec.attachedContainer.object.allowsDetaching = animTime > 0.95 |
130 | |
131 | if (self:getIsAnimationPlaying(spec.refAnimation) or not spec.attachedContainer.limitLocked) and spec.jointLimits ~= nil and not spec.attachedContainer.implement.attachingIsInProgress then |
132 | local v = spec.jointLimits:get(animTime) |
133 | for i=1,3 do |
134 | setJointRotationLimit(spec.attachedContainer.jointIndex, i-1, true, -v[i], v[i]) |
135 | setJointTranslationLimit(spec.attachedContainer.jointIndex, i+2, true, -v[i+3], v[i+3]) |
136 | end |
137 | |
138 | if animTime >= 0.99 then |
139 | spec.attachedContainer.limitLocked = true |
140 | end |
141 | end |
142 | end |
143 | end |
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 HookLiftTrailer.prerequisitesPresent(specializations) |
18 | return SpecializationUtil.hasSpecialization(AnimatedVehicle, specializations) and SpecializationUtil.hasSpecialization(Foldable, specializations) |
19 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
64 | function HookLiftTrailer.registerEventListeners(vehicleType) |
65 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", HookLiftTrailer) |
66 | SpecializationUtil.registerEventListener(vehicleType, "onPostLoad", HookLiftTrailer) |
67 | SpecializationUtil.registerEventListener(vehicleType, "onUpdateTick", HookLiftTrailer) |
68 | SpecializationUtil.registerEventListener(vehicleType, "onPostAttachImplement", HookLiftTrailer) |
69 | SpecializationUtil.registerEventListener(vehicleType, "onPreDetachImplement", HookLiftTrailer) |
70 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
46 | function HookLiftTrailer.registerFunctions(vehicleType) |
47 | SpecializationUtil.registerFunction(vehicleType, "startTipping", HookLiftTrailer.startTipping) |
48 | SpecializationUtil.registerFunction(vehicleType, "stopTipping", HookLiftTrailer.stopTipping) |
49 | SpecializationUtil.registerFunction(vehicleType, "getIsTippingAllowed", HookLiftTrailer.getIsTippingAllowed) |
50 | SpecializationUtil.registerFunction(vehicleType, "getCanDetachContainer", HookLiftTrailer.getCanDetachContainer) |
51 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
55 | function HookLiftTrailer.registerOverwrittenFunctions(vehicleType) |
56 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getIsFoldAllowed", HookLiftTrailer.getIsFoldAllowed) |
57 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "isDetachAllowed", HookLiftTrailer.isDetachAllowed) |
58 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getDoConsumePtoPower", HookLiftTrailer.getDoConsumePtoPower) |
59 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getPtoRpm", HookLiftTrailer.getPtoRpm) |
60 | end |
startTipping
DescriptionCalled on start tippingDefinition
startTipping()Code
185 | function HookLiftTrailer:startTipping() |
186 | local spec = self.spec_hookLiftTrailer |
187 | self:playAnimation(spec.unloadingAnimation, spec.unloadingAnimationSpeed, self:getAnimationTime(spec.unloadingAnimation), true) |
188 | end |
stopTipping
DescriptionCalled on stop tippingDefinition
stopTipping()Code
192 | function HookLiftTrailer:stopTipping() |
193 | local spec = self.spec_hookLiftTrailer |
194 | self:playAnimation(spec.unloadingAnimation, spec.unloadingAnimationReverseSpeed, self:getAnimationTime(spec.unloadingAnimation), true) |
195 | end |