Skip to main content
Skip to main content

TrailerToggleTipSideEvent

TrailerToggleTipSideEvent

Description

Event for toggle trailer tipping

Parent

Event

Functions

emptyNew

Description

Create instance of Event class

Definition

emptyNew()

Return Values

anyselfinstance of class event

Code

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

new

Description

Create new instance of event

Definition

new(table object, boolean isStart, table tipTrigger, integer tipSideIndex)

Arguments

tableobjectobject
booleanisStartis start
tabletipTriggertip trigger
integertipSideIndexindex of tip side

Code

function TrailerToggleTipSideEvent.new(object, tipSideIndex)
local self = TrailerToggleTipSideEvent.emptyNew()
self.object = object
self.tipSideIndex = tipSideIndex
return self
end

readStream

Description

Called on client side on join

Definition

readStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function TrailerToggleTipSideEvent:readStream(streamId, connection)
self.object = NetworkUtil.readNodeObject(streamId)
self.tipSideIndex = streamReadUIntN(streamId, Trailer.TIP_SIDE_NUM_BITS)

self:run(connection)
end

run

Description

Run action on receiving side

Definition

run(Connection connection)

Arguments

Connectionconnectionconnection

Code

function TrailerToggleTipSideEvent:run(connection)
if not connection:getIsServer() then
g_server:broadcastEvent( self , false , connection, self.object)
end

if self.object ~ = nil and self.object:getIsSynchronized() then
self.object:setPreferedTipSide( self.tipSideIndex, true )
end
end

writeStream

Description

Called on server side on join

Definition

writeStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function TrailerToggleTipSideEvent:writeStream(streamId, connection)
NetworkUtil.writeNodeObject(streamId, self.object)
streamWriteUIntN(streamId, self.tipSideIndex, Trailer.TIP_SIDE_NUM_BITS)
end