Sprache Deutsch Language English

Script Dokumentation LS 2015 - Pickup (Patch 1.3)

Script Dokumentation Übersicht

scripts/vehicles/specializations/Pickup.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-- Pickup
3-- This is the specialization for vehicles with a pickup
4--
5-- @author Manuel Leithner
6-- @date 14/01/14
7--
8-- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved.
9
10Pickup = {};
11source("dataS/scripts/vehicles/specializations/PickupSetStateEvent.lua");
12
13function Pickup.prerequisitesPresent(specializations)
14 return true;
15end;
16
17function Pickup:preLoad(xmlFile)
18 assert(self.allowPickingUp == nil, "Pickup needs to be the first specialization which implements allowPickingUp");
19 self.allowPickingUp = Pickup.allowPickingUp;
20end
21
22function Pickup:load(xmlFile)
23
24 self.setPickupState = Pickup.setPickupState;
25 self.isLowered = Utils.overwrittenFunction(self.isLowered, Pickup.isLowered);
26
27 self.isPickupLowered = false;
28 self.pickupAnimationName = Utils.getNoNil(getXMLString(xmlFile, "vehicle.pickupAnimation#name"), "");
29 if self.playAnimation == nil or self.getIsAnimationPlaying == nil then
30 self.pickupAnimationName = "";
31 self.isPickupLowered = true;
32 end;
33 self.pickupAnimationLowerSpeed = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.pickupAnimation#lowerSpeed"), 1);
34 self.pickupAnimationLiftSpeed = Utils.getNoNil(getXMLFloat(xmlFile, "vehicle.pickupAnimation#liftSpeed"), -self.pickupAnimationLowerSpeed);
35
36 if self.pickupAnimationName ~= "" then
37 self.pickupAnimationIsDefaultLowered = Utils.getNoNil(getXMLBool(xmlFile, "vehicle.pickupAnimation#isDefaultLowered"), false);
38 local dir = -20;
39 if self.pickupAnimationIsDefaultLowered then
40 dir = 20;
41 self.isPickupLowered = true;
42 end;
43 self:playAnimation(self.pickupAnimationName, dir, nil, true);
44 AnimatedVehicle.updateAnimations(self, 99999999);
45 end;
46end;
47
48function Pickup:delete()
49end;
50
51function Pickup:readStream(streamId, connection)
52 local isPickupLowered = streamReadBool(streamId);
53 self:setPickupState(isPickupLowered, true);
54end;
55
56function Pickup:writeStream(streamId, connection)
57 streamWriteBool(streamId, self.isPickupLowered);
58end;
59
60function Pickup:mouseEvent(posX, posY, isDown, isUp, button)
61end;
62
63function Pickup:keyEvent(unicode, sym, modifier, isDown)
64end;
65
66function Pickup:update(dt)
67 if self:getIsActiveForInput() then
68 if self.pickupAnimationName ~= "" then
69 if InputBinding.hasEvent(InputBinding.LOWER_IMPLEMENT) then
70 self:setPickupState(not self.isPickupLowered);
71 end;
72 end;
73 end;
74end;
75
76function Pickup:draw()
77 if self.isClient then
78 if self:getIsActiveForInput(true) then
79 if self.pickupAnimationName ~= "" then
80 if self.isPickupLowered then
81 g_currentMission:addHelpButtonText(string.format(g_i18n:getText("lift_OBJECT"), g_i18n:getText("TypeDesc_Pickup")), InputBinding.LOWER_IMPLEMENT);
82 else
83 g_currentMission:addHelpButtonText(string.format(g_i18n:getText("lower_OBJECT"), g_i18n:getText("TypeDesc_Pickup")), InputBinding.LOWER_IMPLEMENT);
84 end;
85 end;
86 end;
87 end;
88end;
89
90function Pickup:setPickupState(isPickupLowered, noEventSend)
91 PickupSetStateEvent.sendEvent(self, isPickupLowered, noEventSend)
92 self.isPickupLowered = isPickupLowered;
93
94 if self.pickupAnimationName ~= "" then
95 local animTime = nil;
96 if self:getIsAnimationPlaying(self.pickupAnimationName) then
97 animTime = self:getAnimationTime(self.pickupAnimationName);
98 end;
99 if isPickupLowered then
100 self:playAnimation(self.pickupAnimationName, self.pickupAnimationLowerSpeed, animTime, true)
101 else
102 self:playAnimation(self.pickupAnimationName, self.pickupAnimationLiftSpeed, animTime, true)
103 end;
104 end;
105end;
106
107function Pickup:allowPickingUp()
108 return self.isPickupLowered;
109end;
110
111function Pickup:isLowered(superFunc, default)
112 if not self.isPickupLowered then
113 return false;
114 end
115
116 if superFunc ~= nil then
117 return superFunc(self, default);
118 end
119 return default;
120end;
121
122function Pickup:onLowerAll(doLowering, jointDescIndex)
123 self:setPickupState(doLowering);
124end;
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