LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

ReceivingHopperSetCreateBoxesEvent

Description
Event for toggle box creation
Parent
Event
Functions

emptyNew

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

new

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

readStream

Description
Called on client side on join
Definition
readStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
33function ReceivingHopperSetCreateBoxesEvent:readStream(streamId, connection)
34 self.object = NetworkUtil.readNodeObject(streamId);
35 self.state = streamReadBool(streamId);
36 self:run(connection);
37end

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
51function ReceivingHopperSetCreateBoxesEvent:run(connection)
52 self.object:setCreateBoxes(self.state, true);
53 if not connection:getIsServer() then
54 g_server:broadcastEvent(ReceivingHopperSetCreateBoxesEvent:new(self.object, self.state), nil, connection, self.object);
55 end;
56end

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
63function ReceivingHopperSetCreateBoxesEvent.sendEvent(vehicle, state, noEventSend)
64 if state ~= vehicle.state then
65 if noEventSend == nil or noEventSend == false then
66 if g_server ~= nil then
67 g_server:broadcastEvent(ReceivingHopperSetCreateBoxesEvent:new(vehicle, state), nil, nil, vehicle);
68 else
69 g_client:getServerConnection():sendEvent(ReceivingHopperSetCreateBoxesEvent:new(vehicle, state));
70 end;
71 end;
72 end;
73end

writeStream

Description
Called on server side on join
Definition
writeStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
43function ReceivingHopperSetCreateBoxesEvent:writeStream(streamId, connection)
44 NetworkUtil.writeNodeObject(streamId, self.object);
45 streamWriteBool(streamId, self.state);
46end