LUADOC - Farming Simulator 17

Printable Version

Script v1.4.4.0

Engine v7.0.0.2

Foundation Reference

GreenhouseSetIsWaterTankFillingEvent

Description
Event for greenhouse tank filling state
Functions

emptyNew

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

new

Description
Create new instance of event
Definition
new(table object, boolean isFilling, table trailer)
Arguments
tableobjectobject
booleanisFillingis filling
tabletrailertrailer
Return Values
tableinstanceinstance of event
Code
26function GreenhouseSetIsWaterTankFillingEvent:new(object, isFilling, trailer)
27 local self = GreenhouseSetIsWaterTankFillingEvent:emptyNew()
28 self.object = object;
29 self.isFilling = isFilling;
30 self.trailer = trailer;
31 return self;
32end;

readStream

Description
Called on client side on join
Definition
readStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
38function GreenhouseSetIsWaterTankFillingEvent:readStream(streamId, connection)
39 self.object = readNetworkNodeObject(streamId);
40 self.isFilling = streamReadBool(streamId);
41 if self.isFilling and not connection:getIsServer() then
42 self.trailer = readNetworkNodeObject(streamId);
43 end;
44 self:run(connection);
45end;

writeStream

Description
Called on server side on join
Definition
writeStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
51function GreenhouseSetIsWaterTankFillingEvent:writeStream(streamId, connection)
52 writeNetworkNodeObject(streamId, self.object);
53 streamWriteBool(streamId, self.isFilling);
54 if self.isFilling and connection:getIsServer() then
55 writeNetworkNodeObject(streamId, self.trailer);
56 end;
57end;

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
62function GreenhouseSetIsWaterTankFillingEvent:run(connection)
63 if not connection:getIsServer() then
64 g_server:broadcastEvent(self, false, connection, self.object);
65 end;
66 self.object:setIsWaterTankFilling(self.isFilling, self.trailer, true);
67end;

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, table trailer, boolean noEventSend)
Arguments
tableobjectobject
booleanisFillingis filling
tabletrailertrailer
booleannoEventSendno event send
Code
75function GreenhouseSetIsWaterTankFillingEvent.sendEvent(object, isFilling, trailer, noEventSend)
76 if isFilling ~= object.isWaterTankFilling then
77 if noEventSend == nil or noEventSend == false then
78 if g_server ~= nil then
79 g_server:broadcastEvent(GreenhouseSetIsWaterTankFillingEvent:new(object, isFilling, trailer), nil, nil, object);
80 else
81 assert(not isFilling or (trailer ~= nil));
82 g_client:getServerConnection():sendEvent(GreenhouseSetIsWaterTankFillingEvent:new(object, isFilling, trailer));
83 end;
84 end;
85 end;
86end;