Skip to main content
Skip to main content

SetCruiseControlStateEvent

SetCruiseControlStateEvent

Description

Event for cruise control state event

Parent

Event

Functions

emptyNew

Description

Create instance of Event class

Definition

emptyNew()

Return Values

anyselfinstance of class event

Code

function SetCruiseControlStateEvent.emptyNew()
local self = Event.new( SetCruiseControlStateEvent _mt)
return self
end

new

Description

Create new instance of event

Definition

new(table vehicle, integer state)

Arguments

tablevehiclevehicle
integerstatestate

Code

function SetCruiseControlStateEvent.new(vehicle, state)
local self = SetCruiseControlStateEvent.emptyNew()
self.state = state
self.vehicle = vehicle
return self
end

readStream

Description

Called on client side on join

Definition

readStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function SetCruiseControlStateEvent:readStream(streamId, connection)
self.vehicle = NetworkUtil.readNodeObject(streamId)
self.state = streamReadUIntN(streamId, 2 )
self:run(connection)
end

run

Description

Run action on receiving side

Definition

run(Connection connection)

Arguments

Connectionconnectionconnection

Code

function SetCruiseControlStateEvent:run(connection)
if self.vehicle ~ = nil and self.vehicle:getIsSynchronized() then
self.vehicle:setCruiseControlState( self.state, true )
end
end

writeStream

Description

Called on server side on join

Definition

writeStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function SetCruiseControlStateEvent:writeStream(streamId, connection)
NetworkUtil.writeNodeObject(streamId, self.vehicle)
streamWriteUIntN(streamId, self.state, 2 )
end