LUADOC - Farming Simulator 17

Printable Version

Script v1.4.4.0

Engine v7.0.0.2

Foundation Reference

BalerSetIsUnloadingBaleEvent

Description
Event for baler is unloading state
Functions

emptyNew

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

new

Description
Create new instance of event
Definition
new(table object, boolean isUnloadingBale)
Arguments
tableobjectobject
booleanisUnloadingBaleis unloading bale
Code
24function BalerSetIsUnloadingBaleEvent:new(object, isUnloadingBale)
25 local self = BalerSetIsUnloadingBaleEvent:emptyNew()
26 self.object = object;
27 self.isUnloadingBale = isUnloadingBale;
28 return self;
29end;

readStream

Description
Called on client side on join
Definition
readStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
35function BalerSetIsUnloadingBaleEvent:readStream(streamId, connection)
36 self.object = readNetworkNodeObject(streamId);
37 self.isUnloadingBale = 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 BalerSetIsUnloadingBaleEvent:writeStream(streamId, connection)
46 writeNetworkNodeObject(streamId, self.object);
47 streamWriteBool(streamId, self.isUnloadingBale);
48end;

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
53function BalerSetIsUnloadingBaleEvent:run(connection)
54 if not connection:getIsServer() then
55 g_server:broadcastEvent(self, false, connection, self.object);
56 end;
57 self.object:setIsUnloadingBale(self.isUnloadingBale, 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 isUnloadingBale, boolean noEventSend)
Arguments
tableobjectobject
booleanisUnloadingBaleisUnloadingBale
booleannoEventSendno event send
Code
65function BalerSetIsUnloadingBaleEvent.sendEvent(object, isUnloadingBale, noEventSend)
66 if noEventSend == nil or noEventSend == false then
67 if g_server ~= nil then
68 g_server:broadcastEvent(BalerSetIsUnloadingBaleEvent:new(object, isUnloadingBale), nil, nil, object);
69 else
70 g_client:getServerConnection():sendEvent(BalerSetIsUnloadingBaleEvent:new(object, isUnloadingBale));
71 end;
72 end;
73end;