LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

GreenhouseSetIsWaterTankFillingEvent

Description
Event for greenhouse tank filling state
Parent
Event
Functions

emptyNew

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

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
24function GreenhouseSetIsWaterTankFillingEvent:new(object, isFilling, trailer)
25 local self = GreenhouseSetIsWaterTankFillingEvent:emptyNew()
26 self.object = object;
27 self.isFilling = isFilling;
28 self.trailer = trailer;
29 return self;
30end

readStream

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

run

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

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
73function GreenhouseSetIsWaterTankFillingEvent.sendEvent(object, isFilling, trailer, noEventSend)
74 if isFilling ~= object.isWaterTankFilling then
75 if noEventSend == nil or noEventSend == false then
76 if g_server ~= nil then
77 g_server:broadcastEvent(GreenhouseSetIsWaterTankFillingEvent:new(object, isFilling, trailer), nil, nil, object);
78 else
79 assert(not isFilling or (trailer ~= nil));
80 g_client:getServerConnection():sendEvent(GreenhouseSetIsWaterTankFillingEvent:new(object, isFilling, trailer));
81 end;
82 end;
83 end;
84end

writeStream

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