LUADOC - Farming Simulator 17

Printable Version

SetIsFillingEvent

Description
Event for set is filling state
Functions

emptyNew

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

new

Description
Create new instance of event
Definition
new(table object, boolean isFilling)
Arguments
tableobjectobject
booleanisFillingis filling
Code
24function SetIsFillingEvent:new(object, isFilling)
25 local self = SetIsFillingEvent: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 SetIsFillingEvent: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 SetIsFillingEvent: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 SetIsFillingEvent:run(connection)
54 if not connection:getIsServer() then
55 g_server:broadcastEvent(self, false, connection, self.object);
56 end;
57 self.object:setIsFilling(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 SetIsFillingEvent.sendEvent(object, isFilling, noEventSend)
66 if isFilling ~= object.isFilling then
67 if noEventSend == nil or noEventSend == false then
68 if g_server ~= nil then
69 g_server:broadcastEvent(SetIsFillingEvent:new(object, isFilling), nil, nil, object);
70 else
71 g_client:getServerConnection():sendEvent(SetIsFillingEvent:new(object, isFilling));
72 end;
73 end;
74 end;
75end;