Sprache Deutsch Language English

Script Dokumentation LS 2015 - GreenhouseSetIsWaterTankFillingEvent (Patch 1.3)

Script Dokumentation Übersicht

scripts/placeables/GreenhouseSetIsWaterTankFillingEvent.lua

Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1-- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved.
2
3GreenhouseSetIsWaterTankFillingEvent = {};
4GreenhouseSetIsWaterTankFillingEvent_mt = Class(GreenhouseSetIsWaterTankFillingEvent, Event);
5
6InitStaticEventClass(GreenhouseSetIsWaterTankFillingEvent, "GreenhouseSetIsWaterTankFillingEvent", EventIds.EVENT_GREENHOUSE_SET_WATER_TANK_FILLING);
7
8function GreenhouseSetIsWaterTankFillingEvent:emptyNew()
9 local self = Event:new(GreenhouseSetIsWaterTankFillingEvent_mt);
10 return self;
11end;
12
13function GreenhouseSetIsWaterTankFillingEvent:new(object, isFilling, trailer)
14 local self = GreenhouseSetIsWaterTankFillingEvent:emptyNew()
15 self.object = object;
16 self.isFilling = isFilling;
17 self.trailer = trailer;
18 return self;
19end;
20
21function GreenhouseSetIsWaterTankFillingEvent:readStream(streamId, connection)
22 self.object = networkGetObject(streamReadInt32(streamId));
23 self.isFilling = streamReadBool(streamId);
24 if self.isFilling and not connection:getIsServer() then
25 self.trailer = networkGetObject(streamReadInt32(streamId));
26 end;
27 self:run(connection);
28end;
29
30function GreenhouseSetIsWaterTankFillingEvent:writeStream(streamId, connection)
31 streamWriteInt32(streamId, networkGetObjectId(self.object));
32 streamWriteBool(streamId, self.isFilling);
33 if self.isFilling and connection:getIsServer() then
34 streamWriteInt32(streamId, networkGetObjectId(self.trailer));
35 end;
36end;
37
38function GreenhouseSetIsWaterTankFillingEvent:run(connection)
39 if not connection:getIsServer() then
40 g_server:broadcastEvent(self, false, connection, self.object);
41 end;
42 self.object:setIsWaterTankFilling(self.isFilling, self.trailer, true);
43end;
44
45function GreenhouseSetIsWaterTankFillingEvent.sendEvent(object, isFilling, trailer, noEventSend)
46 if isFilling ~= object.isWaterTankFilling then
47 if noEventSend == nil or noEventSend == false then
48 if g_server ~= nil then
49 g_server:broadcastEvent(GreenhouseSetIsWaterTankFillingEvent:new(object, isFilling, trailer), nil, nil, object);
50 else
51 assert(not isFilling or (trailer ~= nil));
52 g_client:getServerConnection():sendEvent(GreenhouseSetIsWaterTankFillingEvent:new(object, isFilling, trailer));
53 end;
54 end;
55 end;
56end;
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