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
FrontloaderAttacher
DescriptionSpecialization providing a frontloader attacher dependent on configurationFunctions
- initSpecialization
- onLoad
- onPreAttachImplement
- onPreDetachImplement
- prerequisitesPresent
- registerEventListeners
initSpecialization
DescriptionDefinitioninitSpecialization()Code
29 | function FrontloaderAttacher.initSpecialization() |
30 | g_configurationManager:addConfigurationType("frontloader", g_i18n:getText("configuration_frontloaderAttacher"), nil, nil, nil, nil, ConfigurationUtil.SELECTOR_MULTIOPTION) |
31 | |
32 | local schema = Vehicle.xmlSchema |
33 | schema:setXMLSpecializationType("FrontloaderAttacher") |
34 | |
35 | local basePath = "vehicle.frontloaderConfigurations.frontloaderConfiguration(?)" |
36 | AttacherJoints.registerAttacherJointXMLPaths(schema, basePath .. ".attacherJoint") |
37 | |
38 | schema:register(XMLValueType.BOOL, basePath .. ".attacherJoint#frontAxisLimitJoint", "Front axis joint will be limited while attached", true) |
39 | schema:register(XMLValueType.INT, basePath .. ".attacherJoint#frontAxisJoint", "Front axis joint index", 1) |
40 | |
41 | ObjectChangeUtil.registerObjectChangeXMLPaths(schema, basePath) |
42 | |
43 | schema:setXMLSpecializationType() |
44 | end |
onLoad
DescriptionDefinitiononLoad()Code
48 | function FrontloaderAttacher:onLoad(savegame) |
49 | if self.configurations["frontloader"] ~= nil then |
50 | local spec = self.spec_frontloaderAttacher |
51 | local attacherJointsSpec = self.spec_attacherJoints |
52 | |
53 | spec.attacherJoint = {} |
54 | local key = string.format("vehicle.frontloaderConfigurations.frontloaderConfiguration(%d)", self.configurations["frontloader"]-1) |
55 | if self.xmlFile:hasProperty(key..".attacherJoint") and self:loadAttacherJointFromXML(spec.attacherJoint, self.xmlFile, key..".attacherJoint", 0) then |
56 | table.insert(attacherJointsSpec.attacherJoints, spec.attacherJoint) |
57 | |
58 | local frontAxisLimitJoint = self.xmlFile:getValue(key..".attacherJoint#frontAxisLimitJoint", true) |
59 | if frontAxisLimitJoint then |
60 | local frontAxisJoint = self.xmlFile:getValue(key..".attacherJoint#frontAxisJoint", 1) |
61 | if self.componentJoints[frontAxisJoint] ~= nil then |
62 | spec.frontAxisJoint = frontAxisJoint |
63 | else |
64 | print("Warning: Invalid front-axis joint '"..tostring(frontAxisJoint).."' in '"..self.configFileName.."'") |
65 | end |
66 | end |
67 | |
68 | ObjectChangeUtil.updateObjectChanges(self.xmlFile, "vehicle.frontloaderConfigurations.frontloaderConfiguration", self.configurations["frontloader"], self.components, self) |
69 | else |
70 | -- first config is "no-frontloader"-option |
71 | ObjectChangeUtil.updateObjectChanges(self.xmlFile, "vehicle.frontloaderConfigurations.frontloaderConfiguration", 1, self.components, self) |
72 | spec.attacherJoint = nil |
73 | end |
74 | end |
75 | end |
onPreAttachImplement
DescriptionDefinitiononPreAttachImplement()Code
101 | function FrontloaderAttacher:onPreAttachImplement(attachable, inputJointDescIndex, jointDescIndex) |
102 | local spec = self.spec_frontloaderAttacher |
103 | |
104 | if spec.frontAxisJoint ~= nil then |
105 | local attacherJoint = nil |
106 | local attacherJoints = self:getAttacherJoints() |
107 | if attacherJoints ~= nil then |
108 | attacherJoint = attacherJoints[jointDescIndex] |
109 | end |
110 | if attacherJoint ~= nil then |
111 | if attacherJoint.jointType == AttacherJoints.JOINTTYPE_ATTACHABLEFRONTLOADER and self.isServer then |
112 | -- copy rotlimit |
113 | spec.rotLimit = { unpack(self.componentJoints[spec.frontAxisJoint].rotLimit) } |
114 | for i=1, 3 do |
115 | self:setComponentJointRotLimit(self.componentJoints[spec.frontAxisJoint], i, 0, 0) |
116 | end |
117 | end |
118 | end |
119 | end |
120 | end |
onPreDetachImplement
DescriptionDefinitiononPreDetachImplement()Code
79 | function FrontloaderAttacher:onPreDetachImplement(implement) |
80 | local spec = self.spec_frontloaderAttacher |
81 | |
82 | if spec.frontAxisJoint ~= nil then |
83 | local attacherJoint = nil |
84 | local attacherJointIndex = implement.jointDescIndex |
85 | local attacherJoints = self:getAttacherJoints() |
86 | if attacherJoints ~= nil then |
87 | attacherJoint = attacherJoints[attacherJointIndex] |
88 | end |
89 | if attacherJoint ~= nil then |
90 | if attacherJoint.jointType == AttacherJoints.JOINTTYPE_ATTACHABLEFRONTLOADER and self.isServer then |
91 | for i=1, 3 do |
92 | self:setComponentJointRotLimit(self.componentJoints[spec.frontAxisJoint], i, -spec.rotLimit[i], spec.rotLimit[i]) |
93 | end |
94 | end |
95 | end |
96 | end |
97 | end |
prerequisitesPresent
DescriptionDefinitionprerequisitesPresent()Code
15 | function FrontloaderAttacher.prerequisitesPresent(specializations) |
16 | return SpecializationUtil.hasSpecialization(AttacherJoints, specializations) |
17 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
21 | function FrontloaderAttacher.registerEventListeners(vehicleType) |
22 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", FrontloaderAttacher) |
23 | SpecializationUtil.registerEventListener(vehicleType, "onPreDetachImplement", FrontloaderAttacher) |
24 | SpecializationUtil.registerEventListener(vehicleType, "onPreAttachImplement", FrontloaderAttacher) |
25 | end |