Skip to main content
Skip to main content

BunkerSiloOpenEvent

BunkerSiloOpenEvent

Description

Event for bunker silo open

Parent

Event

Functions

emptyNew

Description

Create instance of Event class

Definition

emptyNew()

Return Values

anyselfinstance of class event

Code

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

new

Description

Create new instance of event

Definition

new(table bunkerSilo, float x, float y, float z)

Arguments

tablebunkerSilobunkerSilo
floatxx opening position
floatyy opening position
floatzz opening position

Return Values

floatinstanceinstance of event

Code

function BunkerSiloOpenEvent.new(bunkerSilo, x,y,z)
local self = BunkerSiloOpenEvent.emptyNew()
self.bunkerSilo = bunkerSilo
self.x = x
self.y = y
self.z = z
return self
end

readStream

Description

Called on client side on join

Definition

readStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function BunkerSiloOpenEvent:readStream(streamId, connection)
if not connection:getIsServer() then
self.bunkerSilo = NetworkUtil.readNodeObject(streamId)
self.x = streamReadFloat32(streamId)
self.y = streamReadFloat32(streamId)
self.z = streamReadFloat32(streamId)
end
self:run(connection)
end

run

Description

Run action on receiving side

Definition

run(Connection connection)

Arguments

Connectionconnectionconnection

Code

function BunkerSiloOpenEvent:run(connection)
if not connection:getIsServer() then
self.bunkerSilo:openSilo( self.x, self.y, self.z)
end
end

writeStream

Description

Called on server side on join

Definition

writeStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function BunkerSiloOpenEvent:writeStream(streamId, connection)
if connection:getIsServer() then
NetworkUtil.writeNodeObject(streamId, self.bunkerSilo)
streamWriteFloat32(streamId, self.x)
streamWriteFloat32(streamId, self.y)
streamWriteFloat32(streamId, self.z)
end
end