LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

ProductionPointOutputModeEvent

Description
Event for production point output mode changes
Parent
Event
Functions

emptyNew

Description
Create instance of Event class
Definition
emptyNew()
Return Values
tableselfinstance of class event
Code
13function ProductionPointOutputModeEvent.emptyNew()
14 local self = Event.new(ProductionPointOutputModeEvent_mt)
15 return self
16end

new

Description
Create new instance of event
Definition
new()
Code
20function ProductionPointOutputModeEvent.new(productionPoint, outputFillTypeId, outputMode)
21 local self = ProductionPointOutputModeEvent.emptyNew()
22 self.productionPoint = productionPoint
23 self.outputFillTypeId = outputFillTypeId
24 self.outputMode = outputMode
25 return self
26end

readStream

Description
Called on client side on join
Definition
readStream()
Code
30function ProductionPointOutputModeEvent:readStream(streamId, connection)
31 self.productionPoint = NetworkUtil.readNodeObject(streamId)
32 self.outputFillTypeId = streamReadUIntN(streamId, FillTypeManager.SEND_NUM_BITS)
33 self.outputMode = streamReadUIntN(streamId, ProductionPoint.OUTPUT_MODE_NUM_BITS)
34 self:run(connection)
35end

run

Description
Run action on receiving side
Definition
run()
Code
47function ProductionPointOutputModeEvent:run(connection)
48 if not connection:getIsServer() then
49 g_server:broadcastEvent(self, false, connection)
50 end
51
52 if self.productionPoint ~= nil then
53 self.productionPoint:setOutputDistributionMode(self.outputFillTypeId, self.outputMode, true)
54 end
55end

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()
Code
59function ProductionPointOutputModeEvent.sendEvent(productionPoint, outputFillTypeId, outputMode, noEventSend)
60 if noEventSend == nil or noEventSend == false then
61 if g_server ~= nil then
62 g_server:broadcastEvent(ProductionPointOutputModeEvent.new(productionPoint, outputFillTypeId, outputMode))
63 else
64 g_client:getServerConnection():sendEvent(ProductionPointOutputModeEvent.new(productionPoint, outputFillTypeId, outputMode))
65 end
66 end
67end

writeStream

Description
Called on server side on join
Definition
writeStream()
Code
39function ProductionPointOutputModeEvent:writeStream(streamId, connection)
40 NetworkUtil.writeNodeObject(streamId, self.productionPoint)
41 streamWriteUIntN(streamId, self.outputFillTypeId, FillTypeManager.SEND_NUM_BITS)
42 streamWriteUIntN(streamId, self.outputMode, ProductionPoint.OUTPUT_MODE_NUM_BITS)
43end