LUADOC - Farming Simulator 17

Printable Version

Script v1.4.4.0

Engine v7.0.0.2

Foundation Reference

HookLiftContainer

Description
Class for hooklift containers
Functions

prerequisitesPresent

Description
Checks if all prerequisite specializations are loaded
Definition
prerequisitesPresent(table specializations)
Arguments
tablespecializationsspecializations
Return Values
booleanhasPrerequisitetrue if all prerequisite specializations are loaded
Code
17function HookLiftContainer.prerequisitesPresent(specializations)
18 return SpecializationUtil.hasSpecialization(AnimatedVehicle, specializations) and SpecializationUtil.hasSpecialization(Attachable, specializations);
19end;

load

Description
Called on loading
Definition
load(table savegame)
Arguments
tablesavegamesavegame
Code
24function HookLiftContainer:load(savegame)
25 self.toggleTipState = Utils.overwrittenFunction(self.toggleTipState, HookLiftContainer.toggleTipState);
26 self.getAllowFillFromAir = Utils.overwrittenFunction(self.getAllowFillFromAir, HookLiftContainer.getAllowFillFromAir);
27 self.getCanTipToGround = Utils.overwrittenFunction(self.getCanTipToGround, HookLiftContainer.getCanTipToGround);
28 self.getCanTip = Utils.overwrittenFunction(self.getCanTip, HookLiftContainer.getCanTip);
29 self.getEndTipIfEmpty = Utils.overwrittenFunction(self.getEndTipIfEmpty, HookLiftContainer.getEndTipIfEmpty);
30
31 self.tiltContainerOnDischarge = Utils.getNoNil(getXMLBool(self.xmlFile, "vehicle.hookLiftContainer#tiltContainerOnDischarge"), true);
32 self.canBeTippedManually = Utils.getNoNil(getXMLBool(self.xmlFile, "vehicle.hookLiftContainer#canBeTippedManually"), false);
33end;

onStartTip

Description
Called on start tipping
Definition
onStartTip(table tipTrigger, integer tipReferencePointIndex, boolean noEventSend, boolean isManuallyTipping)
Arguments
tabletipTriggertip trigger
integertipReferencePointIndexindex of tip reference point
booleannoEventSendno event send
booleanisManuallyTippingnot used anymore
Code
59function HookLiftContainer:onStartTip(tipTrigger, tipReferencePointIndex, noEventSend, isManuallyTipping)
60 -- we can not start tipping while we are tipping with another animation
61 if self.isServer then
62 if self.currentTipReferencePointIndex ~= nil and self.currentTipReferencePointIndex ~= tipReferencePointIndex then
63 return;
64 end
65 end
66 self.isManuallyTipping = isManuallyTipping;
67
68 if self.attacherVehicle ~= nil and self.attacherVehicle.startTipping ~= nil and self.tiltContainerOnDischarge then
69 self.attacherVehicle:startTipping();
70 end;
71end;

onEndTip

Description
Called at the end of tipping
Definition
onEndTip(boolean noEventSend)
Arguments
booleannoEventSendno event send
Code
76function HookLiftContainer:onEndTip(noEventSend)
77 if self.attacherVehicle ~= nil and self.attacherVehicle.stopTipping ~= nil and self.tiltContainerOnDischarge then
78 self.attacherVehicle:stopTipping();
79 self.isManuallyTipping = false;
80 end;
81end;

getAllowFillFromAir

Description
Returns if fill from air is allowed
Definition
getAllowFillFromAir()
Return Values
booleanisAllowedfill from air is allowed
Code
86function HookLiftContainer:getAllowFillFromAir(superFunc)
87 if self.isManuallyTipping then
88 return false;
89 end
90 return superFunc(self);
91end

toggleTipState

Description
Toggle tip state
Definition
toggleTipState(table tipTrigger, integer tipReferencePointIndex, boolean isManuallyTipping)
Arguments
tabletipTriggertip trigger
integertipReferencePointIndexindex of tip reference point
booleanisManuallyTippingnot used anymore
Return Values
booleansuccesssuccess
Code
99function HookLiftContainer:toggleTipState(superFunc, tipTrigger, tipReferencePointIndex, isManuallyTipping)
100 if self.attacherVehicle ~= nil and self.attacherVehicle.isTippingAllowed ~= nil then
101 if not self.attacherVehicle:isTippingAllowed() then
102 -- fold the arm if arm is not fully folded
103 local t = self.attacherVehicle:getAnimationTime("unfoldHand");
104 if t ~= 0 then
105 self.attacherVehicle:setFoldDirection(-1);
106 end;
107 return;
108 end;
109 end;
110
111 if self.isManuallyTipping and (self.tipState == Trailer.TIPSTATE_CLOSING or self.tipState == Trailer.TIPSTATE_CLOSED) then
112 return;
113 end;
114
115 -- Set isManuallyTipping here, so that TrailerToggleTipEvent knows about the state when Trailer:onStartTip calls it
116 self.isManuallyTipping = isManuallyTipping;
117
118 if superFunc ~= nil then
119 superFunc(self, tipTrigger, tipReferencePointIndex, isManuallyTipping);
120 end;
121
122 -- Set isManuallyTipping again, since HookLiftContainer:onStartTip eventually has set it to nil
123 self.isManuallyTipping = isManuallyTipping and self.tipState == Trailer.TIPSTATE_OPENING;
124
125 return true;
126end;

getCanTipToGround

Description
Returns if can be tipped to ground
Definition
getCanTipToGround()
Return Values
booleancanTipToGroundcan tip to ground
Code
131function HookLiftContainer:getCanTipToGround(superFunc)
132 if self.attacherVehicle ~= nil and self.attacherVehicle.isTippingAllowed ~= nil then
133 if not self.attacherVehicle:isTippingAllowed() then
134 return false;
135 end;
136 end;
137
138 if self.fillLevel == 0 and self.canBeTippedManually then
139 return true;
140 end;
141
142 if superFunc ~= nil then
143 return superFunc(self);
144 end;
145 return true;
146end;

getCanTip

Description
Returns if trailer can tip
Definition
getCanTip()
Return Values
booleancanTipcan tip
Code
151function HookLiftContainer:getCanTip(superFunc)
152 if self.fillLevel == 0 and self.canBeTippedManually then
153 return true;
154 end;
155
156 if superFunc ~= nil then
157 return superFunc(self);
158 end;
159 return true;
160end;

getEndTipIfEmpty

Description
Returns if tipping end when the trailer is empty
Definition
getEndTipIfEmpty()
Return Values
booleantipEndIfEmptytipping ends if trailer is empty
Code
165function HookLiftContainer:getEndTipIfEmpty(superFunc)
166 if self.isManuallyTipping then
167 return false;
168 end;
169
170 if superFunc ~= nil then
171 return superFunc(self);
172 end;
173 return true;
174end;