Script v1.4.4.0
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
FrontloaderAttacher
DescriptionClass for vehicles with attachable frontloadersFunctions
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 FrontloaderAttacher.prerequisitesPresent(specializations) |
18 | return SpecializationUtil.hasSpecialization(AttacherJoints, specializations); |
19 | end |
load
DescriptionCalled on loadingDefinition
load(table savegame)Arguments
table | savegame | savegame |
24 | function FrontloaderAttacher:load(savegame) |
25 | if self.configurations["frontloader"] ~= nil then |
26 | self.frontloaderAttacher = {}; |
27 | self.frontloaderAttacher.attacherJoint = {}; |
28 | local key = string.format("vehicle.frontloaderConfigurations.frontloaderConfiguration(%d)", self.configurations["frontloader"]-1); |
29 | if self:loadAttacherJointFromXML(self.frontloaderAttacher.attacherJoint, self.xmlFile, key..".attacherJoint") then |
30 | table.insert(self.attacherJoints, self.frontloaderAttacher.attacherJoint); |
31 | |
32 | local frontAxisLimitJoint = Utils.getNoNil(getXMLBool(self.xmlFile, key..".attacherJoint#frontAxisLimitJoint"), true) |
33 | if frontAxisLimitJoint then |
34 | local frontAxisJoint = Utils.getNoNil(getXMLInt(self.xmlFile, key..".attacherJoint#frontAxisJoint"), 0) |
35 | if self.componentJoints[frontAxisJoint+1] ~= nil then |
36 | self.frontloaderAttacher.frontAxisJoint = frontAxisJoint+1 |
37 | else |
38 | print("Warning: Invalid front-axis joint '"..tostring(frontAxisJoint).."' in '"..self.configFileName.."'") |
39 | end |
40 | end |
41 | |
42 | ObjectChangeUtil.updateObjectChanges(self.xmlFile, "vehicle.frontloaderConfigurations.frontloaderConfiguration", self.configurations["frontloader"], self.components, self); |
43 | else |
44 | -- first config is "no-frontloader"-option |
45 | ObjectChangeUtil.updateObjectChanges(self.xmlFile, "vehicle.frontloaderConfigurations.frontloaderConfiguration", 1, self.components, self); |
46 | self.frontloaderAttacher = nil; |
47 | end |
48 | end |
49 | end |
onDetachImplement
DescriptionCalled on detaching a implementDefinition
onDetachImplement(integer implementIndex)Arguments
integer | implementIndex | index of implement to detach |
69 | function FrontloaderAttacher:onDetachImplement(implementIndex) |
70 | local implement = self.attachedImplements[implementIndex]; |
71 | local attacherJoint = self.attacherJoints[implement.jointDescIndex] |
72 | if attacherJoint.jointType == AttacherJoints.JOINTTYPE_ATTACHABLEFRONTLOADER and self.isServer then |
73 | if self.frontloaderAttacher.frontAxisJoint ~= nil then |
74 | for i=1, 3 do |
75 | self:setComponentJointRotLimit(self.componentJoints[self.frontloaderAttacher.frontAxisJoint], i, -self.frontloaderAttacher.rotLimit[i], self.frontloaderAttacher.rotLimit[i]) |
76 | end |
77 | end |
78 | end |
79 | end |
onAttachImplement
DescriptionCalled on attaching a implementDefinition
onAttachImplement(table implement)Arguments
table | implement | implement to attach |
84 | function FrontloaderAttacher:onAttachImplement(implement) |
85 | local attacherJoint = self.attacherJoints[implement.jointDescIndex] |
86 | if attacherJoint.jointType == AttacherJoints.JOINTTYPE_ATTACHABLEFRONTLOADER and self.isServer then |
87 | if self.frontloaderAttacher.frontAxisJoint ~= nil then |
88 | -- copy rotlimit |
89 | self.frontloaderAttacher.rotLimit = {unpack(self.componentJoints[self.frontloaderAttacher.frontAxisJoint].rotLimit)} |
90 | for i=1, 3 do |
91 | self:setComponentJointRotLimit(self.componentJoints[self.frontloaderAttacher.frontAxisJoint], i, 0, 0) |
92 | end |
93 | end |
94 | end |
95 | end |