LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

SoilSamplerSendEvent

Description
Event for sending taken soil samples for analysation
Parent
Event
Functions

emptyNew

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

new

Description
Create new instance of event
Definition
new(table object)
Arguments
tableobjectobject
Code
21function SoilSamplerSendEvent.new(object)
22 local self = SoilSamplerSendEvent:emptyNew()
23 self.object = object
24 return self
25end

readStream

Description
Called on client side on join
Definition
readStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
31function SoilSamplerSendEvent:readStream(streamId, connection)
32 self.object = NetworkUtil.readNodeObject(streamId)
33 self:run(connection)
34end

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
47function SoilSamplerSendEvent:run(connection)
48 if not connection:getIsServer() then
49 g_server:broadcastEvent(self, false, connection, self.object)
50 end
51
52 if self.object ~= nil and self.object:getIsSynchronized() then
53 self.object:sendTakenSoilSamples(true)
54 end
55end

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 noEventSend)
Arguments
tableobjectobject
booleannoEventSendno event send
Code
61function SoilSamplerSendEvent.sendEvent(object, noEventSend)
62 if noEventSend == nil or noEventSend == false then
63 if g_server ~= nil then
64 g_server:broadcastEvent(SoilSamplerSendEvent.new(object), nil, nil, object)
65 else
66 g_client:getServerConnection():sendEvent(SoilSamplerSendEvent.new(object))
67 end
68 end
69end

writeStream

Description
Called on server side on join
Definition
writeStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
40function SoilSamplerSendEvent:writeStream(streamId, connection)
41 NetworkUtil.writeNodeObject(streamId, self.object)
42end