LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

VehicleSetTurnLightEvent

Description
Event for turn light state
Parent
Event
Functions

emptyNew

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

new

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

readStream

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

run

Description
Run action on receiving side
Definition
run(integer connection)
Arguments
integerconnectionconnection
Code
52function VehicleSetTurnLightEvent:run(connection)
53 if self.object ~= nil and self.object:getIsSynchronized() then
54 self.object:setTurnLightState(self.state, true, true)
55 end
56
57 if not connection:getIsServer() then
58 g_server:broadcastEvent(VehicleSetTurnLightEvent.new(self.object, self.state), 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 VehicleSetTurnLightEvent:writeStream(streamId, connection)
45 NetworkUtil.writeNodeObject(streamId, self.object)
46 streamWriteUIntN(streamId, self.state, Lights.turnLightSendNumBits)
47end