Sprache Deutsch Language English

Script Dokumentation LS 2015 - BaleWrapperStateEvent (Patch 1.3)

Script Dokumentation Übersicht

scripts/vehicles/specializations/BaleWrapperStateEvent.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
3BaleWrapperStateEvent = {};
4BaleWrapperStateEvent_mt = Class(BaleWrapperStateEvent, Event);
5
6InitStaticEventClass(BaleWrapperStateEvent, "BaleWrapperStateEvent", EventIds.EVENT_BALE_WRAPPER_STATE);
7
8function BaleWrapperStateEvent:emptyNew()
9 local self = Event:new(BaleWrapperStateEvent_mt);
10 return self;
11end;
12
13function BaleWrapperStateEvent:new(object, stateId, nearestBaleServerId)
14 local self = BaleWrapperStateEvent:emptyNew()
15 self.object = object;
16 self.stateId = stateId;
17 assert(nearestBaleServerId ~= nil or self.stateId ~= BaleWrapper.CHANGE_GRAB_BALE);
18 self.nearestBaleServerId = nearestBaleServerId;
19 return self;
20end;
21
22function BaleWrapperStateEvent:readStream(streamId, connection)
23 self.object = networkGetObject(streamReadInt32(streamId));
24
25 self.stateId = streamReadInt8(streamId);
26 if self.stateId == BaleWrapper.CHANGE_GRAB_BALE then
27 self.nearestBaleServerId = streamReadInt32(streamId);
28 end;
29 self:run(connection);
30end;
31
32function BaleWrapperStateEvent:writeStream(streamId, connection)
33 streamWriteInt32(streamId, networkGetObjectId(self.object));
34 streamWriteInt8(streamId, self.stateId);
35 if self.stateId == BaleWrapper.CHANGE_GRAB_BALE then
36 streamWriteInt32(streamId, self.nearestBaleServerId);
37 end;
38end;
39
40function BaleWrapperStateEvent:run(connection)
41 self.object:doStateChange(self.stateId, self.nearestBaleServerId);
42end;
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