Sprache Deutsch Language English

Script Dokumentation LS 2015 - BuiltInCutterTrailer (Patch 1.3)

Script Dokumentation Übersicht

scripts/vehicles/specializations/BuiltInCutterTrailer.lua

Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1--
2-- BuiltInCutterTrailer
3--
4--
5-- @author Manuel Leithner
6-- @date 22/05/14
7--
8-- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved.
9
10BuiltInCutterTrailer = {};
11
12function BuiltInCutterTrailer.prerequisitesPresent(specializations)
13 return SpecializationUtil.hasSpecialization(Attachable, specializations) and SpecializationUtil.hasSpecialization(Foldable, specializations);
14end;
15
16function BuiltInCutterTrailer:load(xmlFile)
17
18 self.getIsFoldAllowed = Utils.overwrittenFunction(self.getIsFoldAllowed, BuiltInCutterTrailer.getIsFoldAllowed);
19 self.isDetachAllowed = Utils.overwrittenFunction(self.isDetachAllowed, BuiltInCutterTrailer.isDetachAllowed);
20 self.getIsInputAttacherActive = Utils.overwrittenFunction(self.getIsInputAttacherActive, BuiltInCutterTrailer.getIsInputAttacherActive);
21 self.getCanBeTurnedOn = Utils.overwrittenFunction(self.getCanBeTurnedOn, BuiltInCutterTrailer.getCanBeTurnedOn);
22
23 local i=0;
24 while true do
25 local baseName = string.format("vehicle.movingTools.movingTool(%d)", i);
26 if not hasXMLProperty(xmlFile, baseName) then
27 break;
28 end;
29
30 local node = Utils.indexToObject(self.components, getXMLString(xmlFile, baseName.."#index"));
31 local disableInTrailerMode = Utils.getNoNil(getXMLBool(xmlFile, baseName.."#disableInTrailerMode"), false);
32 for _, tool in pairs(self.movingTools) do
33 if tool.node == node then
34 tool.disableInTrailerMode = disableInTrailerMode;
35 break;
36 end;
37 end;
38 i = i + 1;
39 end;
40
41 self.mouseControlsIconsBackup = self.mouseControlsIcons;
42end;
43
44function BuiltInCutterTrailer:delete()
45end;
46
47function BuiltInCutterTrailer:mouseEvent(posX, posY, isDown, isUp, button)
48end;
49
50function BuiltInCutterTrailer:keyEvent(unicode, sym, modifier, isDown)
51end;
52
53function BuiltInCutterTrailer:update(dt)
54end;
55
56function BuiltInCutterTrailer:draw()
57end;
58
59function BuiltInCutterTrailer:onAttach(attacherVehicle, jointDescIndex)
60 local jointDesc = attacherVehicle.attacherJoints[jointDescIndex];
61 if jointDesc.jointType == Vehicle.JOINTTYPE_CUTTER then
62 self.mouseControlsIcons = self.mouseControlsIconsBackup;
63 for _, tool in pairs(self.movingTools) do
64 if tool.disableInTrailerMode then
65 tool.isActive = true;
66 end;
67 end;
68 self.attachedAsTrailer = false;
69 else
70 self:playAnimation("drawbarSetup", -1, nil, true);
71 self.mouseControlsIcons = {};
72 for _, tool in pairs(self.movingTools) do
73 if tool.disableInTrailerMode then
74 tool.isActive = false;
75 end;
76 end;
77 self.attachedAsTrailer = true;
78 end;
79end;
80
81function BuiltInCutterTrailer:onDetach()
82 if self.attachedAsTrailer then
83 self:playAnimation("drawbarSetup", 1, nil, true);
84 end;
85end;
86
87function BuiltInCutterTrailer:getIsInputAttacherActive(superFunc, inputAttacherJoint)
88 if inputAttacherJoint.jointType == Vehicle.JOINTTYPE_TRAILERLOW then
89 if self.foldAnimTime ~= nil and self.foldAnimTime == 1 then
90 return false;
91 end;
92 end;
93
94 if superFunc ~= nil then
95 return superFunc(self);
96 end
97 return true;
98end;
99
100function BuiltInCutterTrailer:isDetachAllowed(superFunc)
101 if self.foldAnimTime ~= nil then
102 if self.foldAnimTime > 0 and self.foldAnimTime < 1 then
103 return false;
104 end;
105 end;
106
107 if superFunc ~= nil then
108 return superFunc(self);
109 end
110 return true;
111end;
112
113function BuiltInCutterTrailer:getIsFoldAllowed(superFunc)
114 if self.attacherVehicle ~= nil then
115 local implement = self.attacherVehicle:getImplementByObject(self);
116 local jointDesc = self.attacherVehicle.attacherJoints[implement.jointDescIndex];
117 if jointDesc.jointType ~= Vehicle.JOINTTYPE_CUTTER then
118 return false;
119 end;
120 end;
121
122 if superFunc ~= nil then
123 return superFunc(self);
124 end
125 return true;
126end
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
Script Dokumentation Übersicht