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
Pickup
DescriptionSpecialization for vehicles with independently lowerable PickUps (e.g. forage wagon, baler, ...)Functions
- actionControllerLowerPickupEvent
- actionEventTogglePickup
- allowPickingUp
- getCanChangePickupState
- getDirtMultiplier
- getIsLowered
- getWearMultiplier
- initSpecialization
- loadPickupFromXML
- onFoldTimeChanged
- onLoad
- onPostLoad
- onReadStream
- onRootVehicleChanged
- onSetLoweredAll
- onWriteStream
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerLoweringActionEvent
- registerOverwrittenFunctions
- registerSelfLoweringActionEvent
- setPickupState
- updateActionEvents
actionControllerLowerPickupEvent
DescriptionDefinitionactionControllerLowerPickupEvent()Code
148 | function Pickup:actionControllerLowerPickupEvent(direction) |
149 | self:setPickupState(direction > 0) |
150 | end |
actionEventTogglePickup
DescriptionDefinitionactionEventTogglePickup()Code
286 | function Pickup.actionEventTogglePickup(self, actionName, inputValue, callbackState, isAnalog) |
287 | local spec = self.spec_pickup |
288 | if self:getCanChangePickupState(spec, not spec.isLowered) then |
289 | self:setPickupState(not spec.isLowered) |
290 | end |
291 | end |
allowPickingUp
DescriptionDefinitionallowPickingUp()Code
180 | function Pickup:allowPickingUp() |
181 | local spec = self.spec_pickup |
182 | return spec.isLowered |
183 | end |
getCanChangePickupState
DescriptionDefinitiongetCanChangePickupState()Code
213 | function Pickup:getCanChangePickupState(spec, newState) |
214 | return true |
215 | end |
getDirtMultiplier
DescriptionDefinitiongetDirtMultiplier()Code
219 | function Pickup:getDirtMultiplier(superFunc) |
220 | local spec = self.spec_pickup |
221 | |
222 | if spec.isLowered and (self.getIsTurnedOn == nil or self:getIsTurnedOn()) then |
223 | return superFunc(self) + self:getWorkDirtMultiplier() * self:getLastSpeed() / self.speedLimit |
224 | end |
225 | |
226 | return superFunc(self) |
227 | end |
getIsLowered
DescriptionDefinitiongetIsLowered()Code
187 | function Pickup:getIsLowered(superFunc, default) |
188 | local spec = self.spec_pickup |
189 | return spec.isLowered |
190 | end |
getWearMultiplier
DescriptionDefinitiongetWearMultiplier()Code
231 | function Pickup:getWearMultiplier(superFunc) |
232 | local spec = self.spec_pickup |
233 | |
234 | if spec.isLowered and (self.getIsTurnedOn == nil or self:getIsTurnedOn()) then |
235 | return superFunc(self) + self:getWorkWearMultiplier() * self:getLastSpeed() / self.speedLimit |
236 | end |
237 | |
238 | return superFunc(self) |
239 | end |
initSpecialization
DescriptionCalled on specialization initializingDefinition
initSpecialization()Code
25 | function Pickup.initSpecialization() |
26 | local schema = Vehicle.xmlSchema |
27 | schema:setXMLSpecializationType("Pickup") |
28 | |
29 | schema:register(XMLValueType.STRING, Pickup.PICKUP_XML_KEY .. ".animation#name", "Pickup animation name") |
30 | schema:register(XMLValueType.FLOAT, Pickup.PICKUP_XML_KEY .. ".animation#lowerSpeed", "Pickup animation lower speed") |
31 | schema:register(XMLValueType.FLOAT, Pickup.PICKUP_XML_KEY .. ".animation#liftSpeed", "Pickup animation lift speed") |
32 | schema:register(XMLValueType.BOOL, Pickup.PICKUP_XML_KEY .. ".animation#isDefaultLowered", "Pickup animation is default lowered") |
33 | |
34 | schema:setXMLSpecializationType() |
35 | end |
loadPickupFromXML
DescriptionDefinitionloadPickupFromXML()Code
194 | function Pickup:loadPickupFromXML(xmlFile, key, spec) |
195 | XMLUtil.checkDeprecatedXMLElements(xmlFile, "vehicle.pickupAnimation", key .. ".animation") --FS17 to FS19 |
196 | |
197 | spec.isLowered = false |
198 | spec.animationName = xmlFile:getValue(key .. ".animation#name", "") |
199 | if not self:getAnimationExists(spec.animationName) then |
200 | spec.animationName = "" |
201 | spec.isLowered = true |
202 | end |
203 | |
204 | spec.animationLowerSpeed = xmlFile:getValue(key .. ".animation#lowerSpeed", 1) |
205 | spec.animationLiftSpeed = xmlFile:getValue(key .. ".animation#liftSpeed", -spec.animationLowerSpeed) |
206 | spec.animationIsDefaultLowered = xmlFile:getValue(key .. ".animation#isDefaultLowered", false) |
207 | |
208 | return true |
209 | end |
onFoldTimeChanged
DescriptionCalled if fold anim time changesDefinition
onFoldTimeChanged(float foldAnimTime)Arguments
float | foldAnimTime | fold animation time |
142 | function Pickup:onFoldTimeChanged(foldAnimTime) |
143 | Pickup.updateActionEvents(self) |
144 | end |
onLoad
DescriptionDefinitiononLoad()Code
70 | function Pickup:onLoad(savegame) |
71 | self:loadPickupFromXML(self.xmlFile, "vehicle.pickup", self.spec_pickup) |
72 | end |
onPostLoad
DescriptionDefinitiononPostLoad()Code
76 | function Pickup:onPostLoad(savegame) |
77 | local spec = self.spec_pickup |
78 | |
79 | if spec.animationName ~= "" then |
80 | local dir = -20 |
81 | if spec.animationIsDefaultLowered then |
82 | dir = 20 |
83 | spec.isLowered = true |
84 | end |
85 | self:playAnimation(spec.animationName, dir, nil, true) |
86 | AnimatedVehicle.updateAnimations(self, 99999999, true) |
87 | end |
88 | end |
onReadStream
DescriptionDefinitiononReadStream()Code
92 | function Pickup:onReadStream(streamId, connection) |
93 | local isPickupLowered = streamReadBool(streamId) |
94 | self:setPickupState(isPickupLowered, true) |
95 | end |
onRootVehicleChanged
DescriptionCalled if root vehicle changesDefinition
onRootVehicleChanged(table rootVehicle)Arguments
table | rootVehicle | root vehicle |
113 | function Pickup:onRootVehicleChanged(rootVehicle) |
114 | local spec = self.spec_pickup |
115 | if spec.animationName ~= "" then |
116 | local actionController = rootVehicle.actionController |
117 | if actionController ~= nil then |
118 | if spec.controlledAction ~= nil then |
119 | spec.controlledAction:updateParent(actionController) |
120 | return |
121 | end |
122 | |
123 | spec.controlledAction = actionController:registerAction("lowerPickup", InputAction.LOWER_IMPLEMENT, 2) |
124 | spec.controlledAction:setCallback(self, Pickup.actionControllerLowerPickupEvent) |
125 | spec.controlledAction:setFinishedFunctions(self, self.getIsLowered, true, false) |
126 | spec.controlledAction:setIsSaved(true) |
127 | if self:getAINeedsLowering() then |
128 | spec.controlledAction:addAIEventListener(self, "onAIImplementStartLine", 1) |
129 | spec.controlledAction:addAIEventListener(self, "onAIImplementEndLine", -1) |
130 | end |
131 | else |
132 | if spec.controlledAction ~= nil then |
133 | spec.controlledAction:remove() |
134 | end |
135 | end |
136 | end |
137 | end |
onSetLoweredAll
DescriptionDefinitiononSetLoweredAll()Code
106 | function Pickup:onSetLoweredAll(doLowering, jointDescIndex) |
107 | self:setPickupState(doLowering) |
108 | end |
onWriteStream
DescriptionDefinitiononWriteStream()Code
99 | function Pickup:onWriteStream(streamId, connection) |
100 | local spec = self.spec_pickup |
101 | streamWriteBool(streamId, spec.isLowered) |
102 | end |
prerequisitesPresent
DescriptionDefinitionprerequisitesPresent()Code
19 | function Pickup.prerequisitesPresent(specializations) |
20 | return SpecializationUtil.hasSpecialization(AnimatedVehicle, specializations) |
21 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
58 | function Pickup.registerEventListeners(vehicleType) |
59 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", Pickup) |
60 | SpecializationUtil.registerEventListener(vehicleType, "onPostLoad", Pickup) |
61 | SpecializationUtil.registerEventListener(vehicleType, "onReadStream", Pickup) |
62 | SpecializationUtil.registerEventListener(vehicleType, "onWriteStream", Pickup) |
63 | SpecializationUtil.registerEventListener(vehicleType, "onSetLoweredAll", Pickup) |
64 | SpecializationUtil.registerEventListener(vehicleType, "onRootVehicleChanged", Pickup) |
65 | SpecializationUtil.registerEventListener(vehicleType, "onFoldTimeChanged", Pickup) |
66 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
39 | function Pickup.registerFunctions(vehicleType) |
40 | SpecializationUtil.registerFunction(vehicleType, "allowPickingUp", Pickup.allowPickingUp) |
41 | SpecializationUtil.registerFunction(vehicleType, "setPickupState", Pickup.setPickupState) |
42 | SpecializationUtil.registerFunction(vehicleType, "loadPickupFromXML", Pickup.loadPickupFromXML) |
43 | SpecializationUtil.registerFunction(vehicleType, "getCanChangePickupState", Pickup.getCanChangePickupState) |
44 | end |
registerLoweringActionEvent
DescriptionDefinitionregisterLoweringActionEvent()Code
243 | function Pickup:registerLoweringActionEvent(superFunc, actionEventsTable, inputAction, target, callback, triggerUp, triggerDown, triggerAlways, startActive, callbackState, customIconName) |
244 | local spec = self.spec_pickup |
245 | if spec.animationName ~= "" then |
246 | local _, actionEventId = self:addPoweredActionEvent(spec.actionEvents, InputAction.LOWER_IMPLEMENT, self, Pickup.actionEventTogglePickup, triggerUp, triggerDown, triggerAlways, startActive, callbackState, customIconName) |
247 | g_inputBinding:setActionEventTextPriority(actionEventId, GS_PRIO_HIGH) |
248 | |
249 | Pickup.updateActionEvents(self) |
250 | |
251 | if inputAction == InputAction.LOWER_IMPLEMENT then |
252 | return |
253 | end |
254 | end |
255 | |
256 | superFunc(self, actionEventsTable, inputAction, target, callback, triggerUp, triggerDown, triggerAlways, startActive, callbackState, customIconName) |
257 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
48 | function Pickup.registerOverwrittenFunctions(vehicleType) |
49 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getIsLowered", Pickup.getIsLowered) |
50 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getDirtMultiplier", Pickup.getDirtMultiplier) |
51 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getWearMultiplier", Pickup.getWearMultiplier) |
52 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "registerLoweringActionEvent", Pickup.registerLoweringActionEvent) |
53 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "registerSelfLoweringActionEvent", Pickup.registerSelfLoweringActionEvent) |
54 | end |
registerSelfLoweringActionEvent
DescriptionDefinitionregisterSelfLoweringActionEvent()Code
261 | function Pickup:registerSelfLoweringActionEvent(superFunc, actionEventsTable, inputAction, target, callback, triggerUp, triggerDown, triggerAlways, startActive, callbackState, customIconName, ignoreCollisions) |
262 | return Pickup.registerLoweringActionEvent(self, superFunc, actionEventsTable, inputAction, target, callback, triggerUp, triggerDown, triggerAlways, startActive, callbackState, customIconName, ignoreCollisions) |
263 | end |
setPickupState
DescriptionDefinitionsetPickupState()Code
154 | function Pickup:setPickupState(isPickupLowered, noEventSend) |
155 | local spec = self.spec_pickup |
156 | |
157 | if isPickupLowered ~= spec.isLowered then |
158 | PickupSetStateEvent.sendEvent(self, isPickupLowered, noEventSend) |
159 | |
160 | spec.isLowered = isPickupLowered |
161 | |
162 | if spec.animationName ~= "" then |
163 | local animTime = nil |
164 | if self:getIsAnimationPlaying(spec.animationName) then |
165 | animTime = self:getAnimationTime(spec.animationName) |
166 | end |
167 | if isPickupLowered then |
168 | self:playAnimation(spec.animationName, spec.animationLowerSpeed, animTime, true) |
169 | else |
170 | self:playAnimation(spec.animationName, spec.animationLiftSpeed, animTime, true) |
171 | end |
172 | end |
173 | |
174 | Pickup.updateActionEvents(self) |
175 | end |
176 | end |
updateActionEvents
DescriptionDefinitionupdateActionEvents()Code
267 | function Pickup.updateActionEvents(self) |
268 | local spec = self.spec_pickup |
269 | |
270 | if spec.animationName ~= "" then |
271 | local actionEvent = spec.actionEvents[InputAction.LOWER_IMPLEMENT] |
272 | if actionEvent ~= nil then |
273 | if spec.isLowered then |
274 | g_inputBinding:setActionEventText(actionEvent.actionEventId, string.format(g_i18n:getText("action_liftOBJECT"), g_i18n:getText("typeDesc_pickup"))) |
275 | else |
276 | g_inputBinding:setActionEventText(actionEvent.actionEventId, string.format(g_i18n:getText("action_lowerOBJECT"), g_i18n:getText("typeDesc_pickup"))) |
277 | end |
278 | |
279 | g_inputBinding:setActionEventActive(actionEvent.actionEventId, self:getCanChangePickupState(spec, not spec.isLowered)) |
280 | end |
281 | end |
282 | end |