LUADOC - Farming Simulator 17

Printable Version

Script v1.4.4.0

Engine v7.0.0.2

Foundation Reference

ReceivingHopperSetCreateBoxesEvent

Description
Event for toggle box creation
Functions

emptyNew

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

new

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

readStream

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

run

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