Skip to main content
Skip to main content

WashingStationEvent

WashingStationEvent

Description

Event for washing stations

Parent

Event

Functions

emptyNew

Description

Create instance of Event class

Definition

emptyNew()

Return Values

anyselfinstance of class event

Code

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

new

Description

Create new instance of event

Definition

new(table washingStation)

Arguments

tablewashingStationwashingStation

Return Values

tableinstanceinstance of event

Code

function WashingStationEvent.new(washingStation)
local self = WashingStationEvent.emptyNew()
self.washingStation = washingStation
return self
end

readStream

Description

Called on client side on join

Definition

readStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function WashingStationEvent:readStream(streamId, connection)
if not connection:getIsServer() then
self.washingStation = NetworkUtil.readNodeObject(streamId)
end
self:run(connection)
end

run

Description

Run action on receiving side

Definition

run(Connection connection)

Arguments

Connectionconnectionconnection

Code

function WashingStationEvent:run(connection)
if not connection:getIsServer() then
local userId = g_currentMission.userManager:getUserIdByConnection(connection)
if userId ~ = nil then
local farm = g_farmManager:getFarmByUserId(userId)
if farm ~ = nil then
self.washingStation:startWashing(farm.farmId)
end
end
end
end

writeStream

Description

Called on server side on join

Definition

writeStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function WashingStationEvent:writeStream(streamId, connection)
if connection:getIsServer() then
NetworkUtil.writeNodeObject(streamId, self.washingStation)
end
end