LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

PlowPackerStateEvent

Description
Event for setting the plow packer state
Parent
Event
Functions

emptyNew

Description
Create instance of Event class
Definition
emptyNew()
Return Values
tableselfinstance of class event
Code
13function PlowPackerStateEvent.emptyNew()
14 return Event.new(PlowPackerStateEvent_mt)
15end

new

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

readStream

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

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
54function PlowPackerStateEvent:run(connection)
55 if not connection:getIsServer() then
56 g_server:broadcastEvent(self, false, connection, self.object)
57 end
58
59 if self.object ~= nil and self.object:getIsSynchronized() then
60 self.object:setPackerState(self.state, self.updateAnimations, true)
61 end
62end

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 state, boolean updateAnimations, boolean noEventSend)
Arguments
tableobjectobject
booleanstatestate
booleanupdateAnimationsupdateAnimations
booleannoEventSendno event send
Code
70function PlowPackerStateEvent.sendEvent(object, state, updateAnimations, noEventSend)
71 if noEventSend == nil or noEventSend == false then
72 if g_server ~= nil then
73 g_server:broadcastEvent(PlowPackerStateEvent.new(object, state, updateAnimations), nil, nil, object)
74 else
75 g_client:getServerConnection():sendEvent(PlowPackerStateEvent.new(object, state, updateAnimations))
76 end
77 end
78end

writeStream

Description
Called on server side on join
Definition
writeStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
45function PlowPackerStateEvent:writeStream(streamId, connection)
46 NetworkUtil.writeNodeObject(streamId, self.object)
47 streamWriteBool(streamId, self.state)
48 streamWriteBool(streamId, self.updateAnimations)
49end