LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

SetPipeStateEvent

Description
Event for pipe state
Parent
Event
Functions

emptyNew

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

new

Description
Create new instance of event
Definition
new(table object, integer pipeState)
Arguments
tableobjectobject
integerpipeStatepipe state
Code
22function SetPipeStateEvent.new(object, pipeState)
23 local self = SetPipeStateEvent.emptyNew()
24 self.object = object
25 self.pipeState = pipeState
26 assert(self.pipeState >= 0 and self.pipeState < 8)
27 return self
28end

readStream

Description
Called on client side on join
Definition
readStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
34function SetPipeStateEvent:readStream(streamId, connection)
35 self.object = NetworkUtil.readNodeObject(streamId)
36 self.pipeState = streamReadUIntN(streamId, 3)
37 self:run(connection)
38end

run

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

writeStream

Description
Called on server side on join
Definition
writeStream(integer streamId, integer connection)
Arguments
integerstreamIdstreamId
integerconnectionconnection
Code
44function SetPipeStateEvent:writeStream(streamId, connection)
45 NetworkUtil.writeNodeObject(streamId, self.object)
46 streamWriteUIntN(streamId, self.pipeState, 3)
47end