LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

BalerSetIsUnloadingBaleEvent

Description
Event for baler is unloading state
Parent
Event
Functions

emptyNew

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

new

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

readStream

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

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
51function BalerSetIsUnloadingBaleEvent:run(connection)
52 if not connection:getIsServer() then
53 g_server:broadcastEvent(self, false, connection, self.object)
54 end
55
56 if self.object ~= nil and self.object:getIsSynchronized() then
57 self.object:setIsUnloadingBale(self.isUnloadingBale, true)
58 end
59end

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
66function BalerSetIsUnloadingBaleEvent.sendEvent(object, isUnloadingBale, noEventSend)
67 if noEventSend == nil or noEventSend == false then
68 if g_server ~= nil then
69 g_server:broadcastEvent(BalerSetIsUnloadingBaleEvent.new(object, isUnloadingBale), nil, nil, object)
70 else
71 g_client:getServerConnection():sendEvent(BalerSetIsUnloadingBaleEvent.new(object, isUnloadingBale))
72 end
73 end
74end

writeStream

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