Skip to main content
Skip to main content

VehicleLowerImplementEvent

VehicleLowerImplementEvent

Description

Event for lowering implement

Parent

Event

Functions

emptyNew

Description

Create instance of Event class

Definition

emptyNew()

Return Values

anyselfinstance of class event

Code

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

new

Description

Create new instance of event

Definition

new(table vehicle, integer jointIndex, boolean moveDown)

Arguments

tablevehiclevehicle
integerjointIndexindex of joint
booleanmoveDownmove down

Return Values

booleaninstanceinstance of event

Code

function VehicleLowerImplementEvent.new(vehicle, jointIndex, moveDown)
local self = VehicleLowerImplementEvent.emptyNew()
self.jointIndex = jointIndex
self.vehicle = vehicle
self.moveDown = moveDown
return self
end

readStream

Description

Called on client side on join

Definition

readStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function VehicleLowerImplementEvent:readStream(streamId, connection)
self.vehicle = NetworkUtil.readNodeObject(streamId)
self.jointIndex = streamReadInt8(streamId)
self.moveDown = streamReadBool(streamId)
self:run(connection)
end

run

Description

Run action on receiving side

Definition

run(Connection connection)

Arguments

Connectionconnectionconnection

Code

function VehicleLowerImplementEvent:run(connection)
if self.vehicle ~ = nil and self.vehicle:getIsSynchronized() then
self.vehicle:setJointMoveDown( self.jointIndex, self.moveDown, true )
end
if not connection:getIsServer() then
g_server:broadcastEvent( VehicleLowerImplementEvent.new( self.vehicle, self.jointIndex, self.moveDown), nil , connection, self.vehicle)
end
end

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 vehicle, integer jointIndex, boolean moveDown, boolean noEventSend)

Arguments

tablevehiclevehicle
integerjointIndexindex of joint
booleanmoveDownmove down
booleannoEventSendno event send

Code

function VehicleLowerImplementEvent.sendEvent(vehicle, jointIndex, moveDown, noEventSend)
if noEventSend = = nil or noEventSend = = false then
if g_server ~ = nil then
g_server:broadcastEvent( VehicleLowerImplementEvent.new(vehicle, jointIndex, moveDown), nil , nil , vehicle)
else
g_client:getServerConnection():sendEvent( VehicleLowerImplementEvent.new(vehicle, jointIndex, moveDown))
end
end
end

writeStream

Description

Called on server side on join

Definition

writeStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function VehicleLowerImplementEvent:writeStream(streamId, connection)
NetworkUtil.writeNodeObject(streamId, self.vehicle)
streamWriteInt8(streamId, self.jointIndex)
streamWriteBool(streamId, self.moveDown)
end