Sprache Deutsch Language English

Script Dokumentation LS 2015 - Honk (Patch 1.3)

Script Dokumentation Übersicht

scripts/vehicles/specializations/Honk.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-- Honk
3-- Specialization for honking
4--
5-- @author Manuel Leithner
6-- @date 19/12/2013
7--
8-- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved.
9
10Honk = {};
11source("dataS/scripts/vehicles/specializations/HonkEvent.lua");
12
13function Honk.prerequisitesPresent(specializations)
14 return SpecializationUtil.hasSpecialization(Drivable, specializations);
15end;
16
17function Honk:load(xmlFile)
18
19 self.playHonk = SpecializationUtil.callSpecializationsFunction("playHonk");
20
21 if self.isClient then
22 self.sampleHonk = Utils.loadSample(xmlFile, {}, "vehicle.honkSound", nil, self.baseDirectory, self.components[1].node);
23 end;
24end;
25
26function Honk:delete()
27 if self.isClient then
28 Utils.deleteSample(self.sampleHonk);
29 end;
30end;
31
32function Honk:readStream(streamId, connection)
33end;
34
35function Honk:writeStream(streamId, connection)
36end;
37
38function Honk:mouseEvent(posX, posY, isDown, isUp, button)
39end;
40
41function Honk:keyEvent(unicode, sym, modifier, isDown)
42end;
43
44function Honk:update(dt)
45 if self.isEntered and self.isClient and self:getIsActiveForInput(false) then
46 if self.sampleHonk ~= nil then
47 -- only send event if honking key is pressed or released
48 if InputBinding.isPressed(InputBinding.HONK) then
49 if not self.sampleHonk.isPlaying then
50 self:playHonk(true);
51 end;
52 else
53 if self.sampleHonk.isPlaying then
54 self:playHonk(false);
55 end;
56 end;
57 end;
58 end;
59end;
60
61function Honk:updateTick(dt)
62end;
63
64function Honk:draw()
65 if GS_IS_CONSOLE_VERSION then
66 if self.isClient and self:getIsActiveForInput(true) then
67 g_currentMission:addHelpButtonText(g_i18n:getText("Honk"), InputBinding.HONK);
68 end;
69 end;
70end;
71
72function Honk:onDeactivateSounds()
73 if self.isClient then
74 Utils.stopSample(self.sampleHonk, true);
75 Utils.stop3DSample(self.sampleHonk);
76 end;
77end;
78
79function Honk:playHonk(isPlaying, noEventSend)
80 if self.sampleHonk ~= nil then
81 HonkEvent.sendEvent(self, isPlaying, noEventSend);
82
83 if isPlaying then
84 if self:getIsActive() then
85 if self:getIsActiveForSound() then
86 Utils.playSample(self.sampleHonk, 0, 0, nil);
87 elseif self.isControlled then
88 -- enable 3d sound to vehicle on another player's game
89 Utils.play3DSample(self.sampleHonk);
90 end;
91 end;
92 else
93 Honk.onDeactivateSounds(self);
94 end;
95 end;
96end;
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