Sprache Deutsch Language English

Script Dokumentation LS 2015 - MultiSiloTriggerSetIsFillingEvent (Patch 1.3)

Script Dokumentation Übersicht

scripts/triggers/MultiSiloTriggerSetIsFillingEvent.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
3MultiSiloTriggerSetIsFillingEvent = {};
4MultiSiloTriggerSetIsFillingEvent_mt = Class(MultiSiloTriggerSetIsFillingEvent, Event);
5
6InitStaticEventClass(MultiSiloTriggerSetIsFillingEvent, "MultiSiloTriggerSetIsFillingEvent", EventIds.EVENT_MULTI_SILO_TRIGGER_SET_IS_FILLING);
7
8function MultiSiloTriggerSetIsFillingEvent:emptyNew()
9 local self = Event:new(MultiSiloTriggerSetIsFillingEvent_mt);
10 return self;
11end;
12
13function MultiSiloTriggerSetIsFillingEvent:new(object, isFilling, fillType)
14 local self = MultiSiloTriggerSetIsFillingEvent:emptyNew()
15 self.object = object;
16 self.isFilling = isFilling;
17 self.fillType = fillType;
18 return self;
19end;
20
21function MultiSiloTriggerSetIsFillingEvent:readStream(streamId, connection)
22 local id = streamReadInt32(streamId);
23 self.isFilling = streamReadBool(streamId);
24 self.fillType = streamReadUIntN(streamId, Fillable.sendNumBits);
25 self.object = networkGetObject(id);
26 self:run(connection);
27end;
28
29function MultiSiloTriggerSetIsFillingEvent:writeStream(streamId, connection)
30 streamWriteInt32(streamId, networkGetObjectId(self.object));
31 streamWriteBool(streamId, self.isFilling);
32 streamWriteUIntN(streamId, self.fillType, Fillable.sendNumBits);
33end;
34
35function MultiSiloTriggerSetIsFillingEvent:run(connection)
36 if not connection:getIsServer() then
37 g_server:broadcastEvent(MultiSiloTriggerSetIsFillingEvent:new(self.object, self.isFilling, self.fillType), nil, connection, self.object);
38 end;
39 if self.object ~= nil then
40 self.object:setIsFilling(self.isFilling, self.fillType, true);
41 end;
42end;
43
44function MultiSiloTriggerSetIsFillingEvent.sendEvent(object, isFilling, fillType, noEventSend)
45 if isFilling ~= object.isFilling or fillType ~= object.selectedFillType then
46 if noEventSend == nil or noEventSend == false then
47 if g_server ~= nil then
48 g_server:broadcastEvent(MultiSiloTriggerSetIsFillingEvent:new(object, isFilling, fillType), nil, nil, object);
49 else
50 g_client:getServerConnection():sendEvent(MultiSiloTriggerSetIsFillingEvent:new(object, isFilling, fillType));
51 end;
52 end;
53 end;
54end;
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