Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- AIConveyorBelt
- AIImplement
- AIVehicle
- AnimatedVehicle
- ArticulatedAxis
- Attachable
- AttacherJointControl
- AttacherJoints
- BaleGrab
- BaleLoader
- Baler
- BaleWrapper
- BaseMaterial
- BunkerSiloCompacter
- BunkerSiloInteractor
- BuyableBale
- CCTDrivable
- Combine
- ConnectionHoses
- ConveyorBelt
- Cover
- CrabSteering
- Crawlers
- Cultivator
- Cutter
- Cylindered
- CylinderedFoldable
- Dashboard
- Dischargeable
- Drivable
- DynamicallyLoadedParts
- DynamicMountAttacher
- Enterable
- FertilizingCultivator
- FertilizingSowingMachine
- FillTriggerVehicle
- FillUnit
- FillVolume
- Foldable
- FoliageBending
- ForageWagon
- FrontloaderAttacher
- FruitPreparer
- GroundAdjustedNodes
- GroundReference
- Honk
- HookLiftContainer
- HookLiftTrailer
- IKChains
- JigglingParts
- Leveler
- Lights
- LivestockTrailer
- Locomotive
- LogGrab
- ManureBarrel
- MixerWagon
- Motorized
- Mountable
- Mower
- Pickup
- Pipe
- Plow
- PowerConsumer
- PowerTakeOffs
- RandomlyMovingParts
- ReceivingHopper
- ReverseDriving
- Rideable
- RidgeMarker
- Roller
- Ropes
- SemiTrailerFront
- Shovel
- SlopeCompensation
- SmartAttach
- SowingMachine
- SpeedRotatingParts
- SplineVehicle
- Sprayer
- StrawBlower
- StumpCutter
- Suspensions
- Tedder
- TensionBeltObject
- TensionBelts
- TipOccluder
- Trailer
- TreePlanter
- TreeSaw
- TurnOnVehicle
- Washable
- WaterTrailer
- Wearable
- Weeder
- Wheels
- Windrower
- Wipers
- WoodCrusher
- WoodHarvester
- WorkArea
- WorkMode
- WorkParticles
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
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 | end |
onLoad
DescriptionDefinitiononLoad()Code
35 | function FrontloaderAttacher:onLoad(savegame) |
36 | if self.configurations["frontloader"] ~= nil then |
37 | local spec = self.spec_frontloaderAttacher |
38 | local attacherJointsSpec = self.spec_attacherJoints |
39 | |
40 | spec.attacherJoint = {} |
41 | local key = string.format("vehicle.frontloaderConfigurations.frontloaderConfiguration(%d)", self.configurations["frontloader"]-1) |
42 | if hasXMLProperty(self.xmlFile, key..".attacherJoint") and self:loadAttacherJointFromXML(spec.attacherJoint, self.xmlFile, key..".attacherJoint") then |
43 | table.insert(attacherJointsSpec.attacherJoints, spec.attacherJoint) |
44 | |
45 | local frontAxisLimitJoint = Utils.getNoNil(getXMLBool(self.xmlFile, key..".attacherJoint#frontAxisLimitJoint"), true) |
46 | if frontAxisLimitJoint then |
47 | local frontAxisJoint = Utils.getNoNil(getXMLInt(self.xmlFile, key..".attacherJoint#frontAxisJoint"), 1) |
48 | if self.componentJoints[frontAxisJoint] ~= nil then |
49 | spec.frontAxisJoint = frontAxisJoint |
50 | else |
51 | print("Warning: Invalid front-axis joint '"..tostring(frontAxisJoint).."' in '"..self.configFileName.."'") |
52 | end |
53 | end |
54 | |
55 | ObjectChangeUtil.updateObjectChanges(self.xmlFile, "vehicle.frontloaderConfigurations.frontloaderConfiguration", self.configurations["frontloader"], self.components, self) |
56 | else |
57 | -- first config is "no-frontloader"-option |
58 | ObjectChangeUtil.updateObjectChanges(self.xmlFile, "vehicle.frontloaderConfigurations.frontloaderConfiguration", 1, self.components, self) |
59 | spec.attacherJoint = nil |
60 | end |
61 | end |
62 | end |
onPreAttachImplement
DescriptionDefinitiononPreAttachImplement()Code
88 | function FrontloaderAttacher:onPreAttachImplement(attachable, inputJointDescIndex, jointDescIndex) |
89 | local spec = self.spec_frontloaderAttacher |
90 | |
91 | if spec.frontAxisJoint ~= nil then |
92 | local attacherJoint = nil |
93 | local attacherJoints = self:getAttacherJoints() |
94 | if attacherJoints ~= nil then |
95 | attacherJoint = attacherJoints[jointDescIndex] |
96 | end |
97 | if attacherJoint ~= nil then |
98 | if attacherJoint.jointType == AttacherJoints.JOINTTYPE_ATTACHABLEFRONTLOADER and self.isServer then |
99 | -- copy rotlimit |
100 | spec.rotLimit = { unpack(self.componentJoints[spec.frontAxisJoint].rotLimit) } |
101 | for i=1, 3 do |
102 | self:setComponentJointRotLimit(self.componentJoints[spec.frontAxisJoint], i, 0, 0) |
103 | end |
104 | end |
105 | end |
106 | end |
107 | end |
onPreDetachImplement
DescriptionDefinitiononPreDetachImplement()Code
66 | function FrontloaderAttacher:onPreDetachImplement(implement) |
67 | local spec = self.spec_frontloaderAttacher |
68 | |
69 | if spec.frontAxisJoint ~= nil then |
70 | local attacherJoint = nil |
71 | local attacherJointIndex = implement.jointDescIndex |
72 | local attacherJoints = self:getAttacherJoints() |
73 | if attacherJoints ~= nil then |
74 | attacherJoint = attacherJoints[attacherJointIndex] |
75 | end |
76 | if attacherJoint ~= nil then |
77 | if attacherJoint.jointType == AttacherJoints.JOINTTYPE_ATTACHABLEFRONTLOADER and self.isServer then |
78 | for i=1, 3 do |
79 | self:setComponentJointRotLimit(self.componentJoints[spec.frontAxisJoint], i, -spec.rotLimit[i], spec.rotLimit[i]) |
80 | end |
81 | end |
82 | end |
83 | end |
84 | 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 |