Skip to main content
Skip to main content

PurchaseSoilMapsEvent

PurchaseSoilMapsEvent

Description

Event to sync soil map purchase to the server

Parent

Event

Functions

emptyNew

Description

Create instance of Event class

Definition

emptyNew()

Return Values

anyselfinstance of class event

Code

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

new

Description

Create new instance of event

Definition

new(table object)

Arguments

tableobjectobject

Code

function PurchaseSoilMapsEvent.new(farmlandId)
local self = PurchaseSoilMapsEvent.emptyNew()
self.farmlandId = farmlandId
return self
end

readStream

Description

Called on client side on join

Definition

readStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function PurchaseSoilMapsEvent:readStream(streamId, connection)
self.farmlandId = streamReadUIntN(streamId, g_farmlandManager.numberOfBits)
self:run(connection)
end

run

Description

Run action on receiving side

Definition

run(Connection connection)

Arguments

Connectionconnectionconnection

Code

function PurchaseSoilMapsEvent:run(connection)
if not connection:getIsServer() then
if g_precisionFarming ~ = nil then
if g_precisionFarming.soilMap ~ = nil then
g_precisionFarming.soilMap:purchaseSoilMaps( self.farmlandId)
g_precisionFarming:updatePrecisionFarmingOverlays()
end
end
end
end

writeStream

Description

Called on server side on join

Definition

writeStream(integer streamId, Connection connection)

Arguments

integerstreamIdstreamId
Connectionconnectionconnection

Code

function PurchaseSoilMapsEvent:writeStream(streamId, connection)
streamWriteUIntN(streamId, self.farmlandId, g_farmlandManager.numberOfBits)
end