Script Dokumentation LS 2015 - TrainStartEvent (Patch 1.3)
scripts/objects/TrainStartEvent.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 | |
3 | TrainStartEvent = {}; |
4 | TrainStartEvent_mt = Class(TrainStartEvent, Event); |
5 | |
6 | InitStaticEventClass(TrainStartEvent, "TrainStartEvent", EventIds.EVENT_TRAIN_START); |
7 | |
8 | function TrainStartEvent:emptyNew() |
9 | local self = Event:new(TrainStartEvent_mt); |
10 | return self; |
11 | end; |
12 | |
13 | function TrainStartEvent:new(train) |
14 | local self = TrainStartEvent:emptyNew() |
15 | self.train = train; |
16 | return self; |
17 | end; |
18 | |
19 | function TrainStartEvent:readStream(streamId, connection) |
20 | local id = streamReadInt32(streamId); |
21 | self.train = networkGetObject(id); |
22 | self:run(connection); |
23 | end; |
24 | |
25 | function TrainStartEvent:writeStream(streamId, connection) |
26 | streamWriteInt32(streamId, networkGetObjectId(self.train)); |
27 | end; |
28 | |
29 | function TrainStartEvent:run(connection) |
30 | if not connection:getIsServer() then |
31 | g_server:broadcastEvent(self, false, connection, self.train) |
32 | end; |
33 | self.train:startTrain(true); |
34 | end; |
35 | |
36 | function TrainStartEvent.sendEvent(train, noEventSend) |
37 | if noEventSend == nil or noEventSend == false then |
38 | if g_server ~= nil then |
39 | g_server:broadcastEvent(TrainStartEvent:new(train), nil, nil, train); |
40 | else |
41 | g_client:getServerConnection():sendEvent(TrainStartEvent:new(train)); |
42 | end; |
43 | end; |
44 | end;
|
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de