LUADOC - Farming Simulator 17

Printable Version

Script v1.4.4.0

Engine v7.0.0.2

Foundation Reference

WaterTrailerSetIsFillingEvent

Description
Event for water trailer filling
Functions

emptyNew

Description
Create instance of Event class
Definition
emptyNew()
Return Values
tableselfinstance of class event
Code
15function WaterTrailerSetIsFillingEvent:emptyNew()
16 local self = Event:new(WaterTrailerSetIsFillingEvent_mt);
17 return self;
18end;

new

Description
Create new instance of event
Definition
new(table object, boolean isFilling)
Arguments
tableobjectobject
booleanisFillingis filling
Code
24function WaterTrailerSetIsFillingEvent:new(object, isFilling)
25 local self = WaterTrailerSetIsFillingEvent:emptyNew()
26 self.object = object;
27 self.isFilling = isFilling;
28 return self;
29end;

readStream

Description
Called on client side on join
Definition
readStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
35function WaterTrailerSetIsFillingEvent:readStream(streamId, connection)
36 self.object = readNetworkNodeObject(streamId);
37 self.isFilling = streamReadBool(streamId);
38 self:run(connection);
39end;

writeStream

Description
Called on server side on join
Definition
writeStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
45function WaterTrailerSetIsFillingEvent:writeStream(streamId, connection)
46 writeNetworkNodeObject(streamId, self.object);
47 streamWriteBool(streamId, self.isFilling);
48end;

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
53function WaterTrailerSetIsFillingEvent:run(connection)
54 if not connection:getIsServer() then
55 g_server:broadcastEvent(self, false, connection, self.object);
56 end;
57 self.object:setIsWaterTrailerFilling(self.isFilling, true);
58end;

sendEvent

Description
Broadcast event from server to all clients, if called on client call function on server and broadcast it to all clients
Definition
sendEvent(table object, boolean isFilling, boolean noEventSend)
Arguments
tableobjectobject
booleanisFillingis filling
booleannoEventSendno event send
Code
65function WaterTrailerSetIsFillingEvent.sendEvent(object, isFilling, noEventSend)
66 if isFilling ~= object.isWaterTrailerFilling then
67 if noEventSend == nil or noEventSend == false then
68 if g_server ~= nil then
69 g_server:broadcastEvent(WaterTrailerSetIsFillingEvent:new(object, isFilling), nil, nil, object);
70 else
71 g_client:getServerConnection():sendEvent(WaterTrailerSetIsFillingEvent:new(object, isFilling));
72 end;
73 end;
74 end;
75end;