LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

LocomotiveStateEvent

Description
Event for locomotive state
Parent
Event
Functions

emptyNew

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

new

Description
Create new instance of event
Definition
new(table object, boolean state)
Arguments
tableobjectobject
booleanstatestate
Code
22function LocomotiveStateEvent.new(object, state)
23 local self = LocomotiveStateEvent.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 LocomotiveStateEvent:readStream(streamId, connection)
34 self.object = NetworkUtil.readNodeObject(streamId)
35 self.state = streamReadUIntN(streamId, Locomotive.NUM_BITS_STATE)
36 self:run(connection)
37end

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
51function LocomotiveStateEvent:run(connection)
52 if self.object ~= nil and self.object:getIsSynchronized() then
53 self.object:setLocomotiveState(self.state, true)
54 end
55end

writeStream

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